首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >对象映射[位置]不能从嵌套更改为非嵌套。

对象映射[位置]不能从嵌套更改为非嵌套。
EN

Stack Overflow用户
提问于 2016-08-19 11:25:56
回答 1查看 5.1K关注 0票数 2

Step1:

放置http://localhost:9200/hindex

代码语言:javascript
复制
  {
      "mappings" : {
            "hProvider":{
                "properties": {
                    "iPid"  : { 
                        "type": "string"
                    },
                    "pType" : {
                        "type" : "string"
                    },
                    "pInfo" : {
                        "properties":{
                            "businessName": {
                                "type": "string"
                            },
                            "dob": {
                                "type": "string"
                            },
                            "firstName": {
                                "type": "string"
                            },
                            "gender": {
                                "type": "string",
                                "index": "not_analyzed"
                            }
                        }
                    },
                    "locations" : {
                        "type" : "nested",
                        "properties" :  {
                            "addressInfo" : {
                               "properties" : {
                                        "city": {
                                              "type": "string",
                                              "index": "not_analyzed"
                                        },
                                        "county": {
                                              "type": "string",
                                              "index": "not_analyzed"
                                        }
                                }
                            }
                        }
                    }
                }
            }
        }
    }

获取mapping

代码语言:javascript
复制
{"hindex":{"mappings":{"hProvider":{"properties":{"iPid":{"type":"string"},"locations":{"type":"nested","properties":{"addressInfo":{"properties":{"city":{"type":"string","index":"not_analyzed"},"county":{"type":"string","index":"not_analyzed"}}}}},"pInfo":{"properties":{"businessName":{"type":"string"},"dob":{"type":"string"},"firstName":{"type":"string"},"gender":{"type":"string","index":"not_analyzed"}}},"pType":{"type":"string"}}}}}}
  1. 插入数据

POST create

代码语言:javascript
复制
{
               "iPid"  :  "xyz",
               "pType" : "HealthCareProfessional",
               "pInfo": {
                  "businessName" : "hdata",
                  "firstName" : "Dawoods",           
                  "dob" : "11/18/1975",
                  "gender" : "male"
                },
                "locations" : [
                    {
                        "addressInfo" : {  "city" : "Olney",  "county" : "UnitedStates" } 
                    }, 
                    {
                        "addressInfo" :  {  "city" : "Rivers", "county" : "United States" }
                    }
                ]
}

答复:

代码语言:javascript
复制
{"error":{"root_cause":[{"type":"remote_transport_exception","reason":"[node-1][10.194.153.161:9300][indices:data/write/index[p]]"}],"type":"illegal_argument_exception","reason":"object mapping [locations] can't be changed from nested to non-nested"},"status":400}

尝试过不同的数据集,但是没有运气,数据上的错误是什么?

EN

Stack Overflow用户

回答已采纳

发布于 2016-08-19 11:40:07

第三个命令不正确,它没有在正确的映射类型上运行,它试图创建一个名为prof的新映射类型,其中包含一个非嵌套的locations字段,该字段与同一索引中的hProvider映射类型中的嵌套字段发生冲突。

将其更改为:

代码语言:javascript
复制
POST http://localhost:9200/hindex/hProvider/1/?_create
                                     ^
                                     |
                                change this
票数 2
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39037883

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档