对象映射[位置]不能从嵌套更改为非嵌套(object mapping [locations] can't be changed from nested to non

编程入门 行业动态 更新时间:2024-10-19 17:32:05
对象映射[位置]不能从嵌套更改为非嵌套(object mapping [locations] can't be changed from nested to non-nested)

步骤1:

PUT http:// localhost:9200 / hindex

{ "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" } } } } } } } } }

Step1:

PUT http://localhost:9200/hindex

{ "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" } } } } } } } } }

GET http://localhost:9200/hindex/_mapping

{"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"}}}}}} Inserting data

POST http://localhost:9200/hindex/prof/1/?_create

{ "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" } } ] }

Response :

{"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}

Have tried with different data-sets but no luck, what could be the error on the data ?

最满意答案

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

把它改成这个:

POST http://localhost:9200/hindex/hProvider/1/?_create ^ | change this

Your third command is not correct, it's not running on the correct mapping type and it tries to create a new mapping type called prof with a non-nested locations field, which conflicts with the nested one in the hProvider mapping type in the same index.

Change it to this:

POST http://localhost:9200/hindex/hProvider/1/?_create ^ | change this

更多推荐

本文发布于:2023-04-28 03:27:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1329767.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:嵌套   对象   位置   object   nested

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!