gpt4 book ai didi

elasticsearch - 我的 Elasticsearch 查询有什么问题?获取预期的最终对象错误

转载 作者:行者123 更新时间:2023-12-04 06:04:59 29 4
gpt4 key购买 nike

我正在尝试执行一个 elasticsearch 查询,该查询执行地理定位过滤器并对嵌套文档进行一些匹配,但每当我在嵌套查询中添加时都会收到此错误。

"[bool] malformed query, expected [END_OBJECT] but found [FIELD_NAME]"

{
"sort": [
{
"_score": {
"order": "desc"
}
}
],
"query": {
"bool": {
"filter": {
"geo_distance": {
"distance": "10km",
"geolocation": [
-73.980090948125,
40.747844918436
]
}
},
"must": {
"multi_match": {
"query": "New York",
"fields": [
"name^2",
"city",
"state",
"zip"
],
"type": "best_fields"
}
}
},
"nested": {
"path": "amenities",
"query": {
"bool": {
"must": [
{
"match": {
"amenities.name": "Pool"
}
}
]
}
}
}
},
"aggs": {
"reviews": {
"nested": {
"path": "reviews"
},
"aggs": {
"avg_rating": {
"avg": {
"field": "reviews.rating"
}
}
}
}
}
}

最佳答案

你只是放错了嵌套查询,试试这样:

{
"sort": [
{
"_score": {
"order": "desc"
}
}
],
"query": {
"bool": {
"filter": {
"geo_distance": {
"distance": "10km",
"geolocation": [
-73.980090948125,
40.747844918436
]
}
},
"must": [
{
"multi_match": {
"query": "New York",
"fields": [
"name^2",
"city",
"state",
"zip"
],
"type": "best_fields"
}
},
{
"nested": {
"path": "amenities",
"query": {
"match": {
"amenities.name": "Pool"
}
}
}
}
]
}
},
"aggs": {
"reviews": {
"nested": {
"path": "reviews"
},
"aggs": {
"avg_rating": {
"avg": {
"field": "reviews.rating"
}
}
}
}
}
}

关于elasticsearch - 我的 Elasticsearch 查询有什么问题?获取预期的最终对象错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41651629/

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