Constant keyword field type

Introduced 2.14

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:

  1. PUT romcom_movies
  2. {
  3. "mappings" : {
  4. "properties" : {
  5. "genre" : {
  6. "type": "constant_keyword",
  7. "value" : "Romantic comedy"
  8. }
  9. }
  10. }
  11. }

copy

Parameters

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

ParameterDescription
valueThe string field value for all documents in the index.