← Main page

Elasticsearch query DSL

Boolean query

A query that matches documents matching boolean combinations of other queries.

Term query

  • Returns documents that contain an exact term in a provided field. Avoid using the term query for text fields.
{
  "query": {
    "term": {
      "user.id": {
        "value": "123"
      }
    }
  }
}

Range query

  • Returns documents that contain terms within a provided range.
{
  "query": {
    "range": {
      "age": {
        "gte": 10,
        "lte": 20
      }
    }
  }
}

Nested query

  • The nested query searches nested field objects as if they were indexed as separate documents. If an object matches the search, the nested query returns the root parent document.
  • To use the nested query, your index must include a nested field mapping.

Match query

  • Returns documents that match a provided text, number, date or boolean value. The provided text is analyzed before matching. The match query is the standard query for performing a full-text search, including options for fuzzy matching.
{
  "query": {
    "match": {
      "message": "this is a test"
    }
  }
}

Explain

Returns information about why a specific document matches (or doesn’t match) a query.