0
votes

I have the following 2 queries:

GET places/_search
{
  "query": {
    "filtered": {
      "filter": {
        "bool": {
          "should": [
            {
              "term": {
                "approved": false
              }
            }
          ]
        }
      }
    }
  }
}

GET places/_search
{
  "query": {
    "filtered": {
      "filter": {
        "geo_bounding_box": {
          "loc": {
            "top_left": "54.6152065515344, -6.09334913041994",
            "bottom_right": "54.5754258987271, -5.76633420732423"
          }
        }
      }
    }
  }
}

Both work fine, however I am having issues combining the queries and was wondering if anyone could help. Basically I want to retuen all items within the bounding box specified, where the "approved" property is false.

1

1 Answers

1
votes

You can keep your filtered query and merge both conditions simply like this inside in a bool/mustfilter

curl -XPOST localhost:9200/places/_search -d '{
  "query": {
    "filtered": {
      "filter": {
        "bool": {
          "must": [
            {
              "term": {
                "approved": false
              }
            },
            {
              "geo_bounding_box": {
                "loc": {
                  "top_left": "54.6152065515344, -6.09334913041994",
                  "bottom_right": "54.5754258987271, -5.76633420732423"
                }
              }
            }
          ]
        }
      }
    }
  }
}'