gpt4 book ai didi

elasticsearch - 当未为搜索提供对象名称时,嵌套过滤器返回错误结果

转载 作者:行者123 更新时间:2023-11-29 02:56:59 25 4
gpt4 key购买 nike

使用 Elasticsearch ,我正在尝试获取嵌套对象的数据

BoolQueryBuilder boolBuilder = QueryBuilders.boolQuery();
NestedQueryBuilder nestedBuilder = QueryBuilders.nestedQuery("Attributes", boolBuilder);
boolBuilder.must(QueryBuilders.termQuery("Attributes.attributeId", "1001"));

这样查询就有结果,

 {
"nested" : {
"query" : {
"bool" : {
"must" : [ {
"term" : {
"Attributes.attributeId" : "1001"
}
]
}
},
"path" : "Attributes"
}'

这样查询不会有结果

 {    
"nested" : {
"query" : {
"bool" : {
"must" : [ {
"term" : {
"attributeId" : "1001"
}
]
}
},
"path" : "Attributes"
}

有人可以帮助我吗?我必须在不使用“Attributes.attributeId”的情况下获得结果。即。单独使用“attributeId”数据必须来。

最佳答案

这符合嵌套查询 documentation 的预期

The query path points to the nested object path, and the query (or filter) includes the query that will run on the nested docs matching the direct path, and joining with the root parent docs. Note that any fields referenced inside the query must use the complete path (fully qualified).

关于elasticsearch - 当未为搜索提供对象名称时,嵌套过滤器返回错误结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33345225/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com