我在尝试查询嵌套字段时遇到了这个错误,这个问题似乎在重复,但没有什么变化,而设置字段的Map时,我没有指定嵌套的,但创建了嵌套Map。现在,当我尝试使用gremlin查询do neptune全文搜索查询时,它正在工作,但当我尝试执行本机查询时,它给出以下错误:
failed to create a query: [nested] nested object under path [predicates] is not of nested type
ElasticSearch索引Map
{
"amazon_neptune" : {
"mappings" : {
"properties" : {
"aggregateId" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"document_type" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"entity_id" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"entity_type" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"predicates" : {
"properties" : {
"group_name" : {
"properties" : {
"value" : {
"type" : "text",
"analyzer" : "autocomplete_analyzer",
"search_analyzer" : "standard"
}
}
},
"question" : {
"properties" : {
"value" : {
"type" : "text",
"analyzer" : "questions_auto_complete_analyzer",
"search_analyzer" : "standard"
}
}
},
"suggestion" : {
"properties" : {
"value" : {
"type" : "text",
"analyzer" : "autocomplete_analyzer",
"search_analyzer" : "standard"
}
}
},
"type" : {
"properties" : {
"value" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
}
},
"user_name" : {
"properties" : {
"value" : {
"type" : "text",
"analyzer" : "autocomplete_analyzer",
"search_analyzer" : "standard"
}
}
}
}
}
}
}
}
}
正在运行的gremlin查询
g.withSideEffect('Neptune#fts.endpoint',ES Endpoint).withSideEffect('Neptune#fts.queryType', 'match').V().has('suggestion','Neptune#fts life').limit(5).valueMap().toList()
elasticsearch查询出错:
{
"query": {
"bool": {
"must": [
{
"term": {
"entity_type": "suggestions"
}
},
{
"term": {
"document_type": "vertex"
}
},
{
"nested": {
"path": "predicates",
"query": {
"nested": {
"path": "predicates.suggestion",
"query": {
"match": {
"predicates.suggestion.value": "life"
}
}
}
}
}
}
]
}
}
}
如果这个查询有什么问题,请告诉我。
2条答案
按热度按时间rdrgkggo1#
添加索引数据、Map、搜索查询和搜索结果的工作示例
索引Map:
索引数据:
运行相同的搜索查询,如问题中所示:
搜索结果:
svmlkihl2#
我没有指定嵌套Map,但创建了嵌套Map
这就是问题所在。如果你不指定
"type": "nested"
显然,那么predicates
不会是那种类型的nested
但属于object
相反,您的查询将无法正常工作。你需要明确定义
predicates
作为nested
在你的Map上,没有别的方法了。更新
本机查询应如下所示: