弹性搜索的OR条件


OR condition for Elastic search

我试图根据geo_point的OR条件找到结果,并按距离排序。我已经在这里发布了我尝试OR条件的代码。这显示了错误没有为[应该]注册查询

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

但它显示错误[geo_distance]查询不支持[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"
              }
            }
          ]
        }
      }
    }
  }
}