Link Search Menu Expand Document Documentation Menu

Constant keyword field type

A constant keyword field uses the same value for all documents in the index.

When a search request spans multiple indexes, you can filter on a constant keyword field to match documents from indexes with the given constant value but not from indexes with a different value.

Example

The following query creates a mapping with a constant keyword field:

PUT romcom_movies
{
  "mappings" : {
    "properties" : {
      "genre" : {
        "type": "constant_keyword",
        "value" : "Romantic comedy"
      }
    }
  }
}

Parameters

The following table lists the parameters accepted by constant keyword field types. All values are required.

Parameter Description
value The string field value for all documents in the index.
350 characters left

Have a question? .

Want to contribute? or .