Regexp query

Regexp query #

Returns documents that contain terms matching a regular expression.

A regular expression is a way to match patterns in data using placeholder characters, called operators. For a list of operators supported by the regexp query, see Regular expression syntax.

Inside a nested query: not supported yet — the clause is rejected with an HTTP 400 naming the offending clause.

Examples #

The following search returns documents where the org.id field contains any term that begins with in and ends with y. The .* operators match any characters of any length, including no characters. Matching terms can include ini, inni, and infini.

GET /_search
{
  "query": {
    "regexp": {
      "field": "org.id",
      "value": "in.*i",
      "case_insensitive": true
    }
  }
}

Parameters for regexp #

  • field
    (Required, string) Field you wish to search.
  • value
    (Required, string) Regular expression for terms you wish to find in the provided field. For a list of supported operators, see Regular expression syntax.
  • case_insensitive
    (Optional, boolean) Allows ASCII case insensitive matching of the value with the indexed field values when set to true. Default is false.
  • flags
    (Optional, string) Regex flags.
  • max_determinized_states
    (Optional, integer) Safety cap on automaton complexity.
  • boost
    (Optional, float, default: 1.0) Decrease or increase the relevance scores of the query.
  • rewrite
    (Optional, string) Method used to rewrite the query (constant_score, scoring_boolean, …).
Calendar September 27, 2026
Edit Edit this page