gpt4 book ai didi

php - Elasticsearch 的 OR 条件

转载 作者:搜寻专家 更新时间:2023-10-31 21:25:30 26 4
gpt4 key购买 nike

我正在尝试根据 OR 条件与 geo_point 查找结果并按距离排序。我已经在此处发布了我尝试用于 OR 条件的代码。这向我显示错误 No query registered for [should]

{
"query": {
"filtered": {
"filter": {
"geo_distance": {
"distance": "5000km",
"location": {
"lat": 28.613939,
"lon": 77.209021
}
},
"bool": {
"should": [
{
"term": {
"maincat_id": "55b2326501fcff8a338b4569"
}
}
]
}
}
}}}

但它显示错误 [geo_distance] query does not support [bool]请帮我解决一下

最佳答案

这个怎么样?

{
"query": {
"filtered": {
"filter": {
"bool": {
"must": [
{
"geo_distance": {
"distance": "5000km",
"location": {
"lat": 28.613939,
"lon": 77.209021
}
}
}
],
"should": [
{
"term": {
"maincat_id": "55b2326501fcff8a338b4569"
}
},
{
"term": {
"maincat_id": "55b2326501fcff8a338b4578"
}
},
{
"term": {
"maincat_id": "567a47e801fcff55228b4567"
}
}
]
}
}
}
}
}

关于php - Elasticsearch 的 OR 条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37163104/

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