labs

This lab has been modernised but not yet verified end to end. Tell us if something breaks.

Searching with the Query DSL

45 dkdockerView on GitHub

Lab Hints

You can click the Inspect option in the menu at the top right of Discover page to see the actual Query DSL - but it produces a query which is more complex than you need.

If you start from scratch instead, then the first thing is you can't add a filter clause to a straight match query, you need to use a boolean - the bool query can have a single match, and then the filter goes alongside.

The filter clause takes an array, where each element can be an exact term to match, or a range.

You can get a head-start using this template.
{ 
    "query": 
    {
      "bool" : {
        "must" : {
          "match" : { <query goes here> }
        },
      "filter": [
        { "term" : { <term filter> }},
        ...
        { "range": { <range filter> }}
      ]
    }
  }
}

Need more? Here's the solution.