我在弹性搜索中有一些索引数据,我正在尝试使用邮递员通过以下请求获取数据。
{
"_source": ["_id"],
"query": {
"nested" : {
"path" : "data",
"query" : {
"bool" : {
"must" : [
{ "match" : {"data.id": "3456"} }
]
}
},
"score_mode" : "avg"
}
}
}
但是我要例外了
[nested] nested object under path [data] is not of nested type
我的映射定义就像
{
"property": {
"mappings": {
"property": {
"properties": {
"data": {
"properties": {
"id": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
},
"point": {
"properties": {
"lat": {
"type": "float"
},
"lon": {
"type": "float"
}
}
},
"popId": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
}
}
知道为什么会发生吗?
答案 0 :(得分:1)
字段data
是一个对象,因此其类型应为嵌套。
请尝试以下映射配置:
PUT property
{
"mappings": {
"property": {
"properties": {
"point": {
"properties": {
"lat": {
"type": "float"
},
"lon": {
"type": "float"
}
}
},
"popId": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"data": {
"type": "nested",
"properties": {
"id": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
}
}
}
您将必须删除索引,并使用新的映射配置重新创建它。
如果您不想删除数据,则可能help
希望有帮助