9951 explained code solutions for 126 technologies

elasticsearchHow do I perform an exact match search in Elasticsearch?

To perform an exact match search in Elasticsearch, you can use the term query. This query will match documents that have exact terms specified in the query.

For example, if you have a field title with value The quick brown fox, the following query will match the document:

GET /_search
  "query": {
    "term": {
      "title": {
        "value": "The quick brown fox"

The output will be the document:

  "_index": "my_index",
  "_type": "_doc",
  "_id": "1",
  "_score": 1,
  "_source": {
    "title": "The quick brown fox"

The term query consists of the following parts:

  • query: The query type, in this case term
  • title: The field to search in
  • value: The exact value to search for

For more information, see the Elasticsearch documentation.

Edit this code on GitHub