简体   繁体   English

弹性搜索的OR条件

[英]OR condition for Elastic search

i am trying to find results based on OR condition with geo_point and sort by distance. 我试图找到基于OR条件的结果与geo_point并按距离排序。 I have posted here code which i tried for OR condition. 我在这里发布了我为OR条件尝试过的代码。 This shows me error No query registered for [should] 这显示我错误没有为[should]注册的查询

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

but its shows me error [geo_distance] query does not support [bool] please help me to solve it out 但它显示我错误[geo_distance]查询不支持[bool]请帮我解决

How about this ? 这个怎么样 ?

{
  "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"
              }
            }
          ]
        }
      }
    }
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM