From 7f65cda416fd977d35d5ae0f20752383d4f39a41 Mon Sep 17 00:00:00 2001 From: Michael Froh Date: Thu, 23 May 2024 16:55:51 +0000 Subject: [PATCH] Add documentation for `constant_keyword` field type (#7235) * Add documentation for `constant_keyword` field type Signed-off-by: Michael Froh * Fix nav_order and bad copy/pasted table entry Signed-off-by: Michael Froh * Doc review Signed-off-by: Fanit Kolchina * Apply suggestions from code review Co-authored-by: Nathan Bower Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> * Update _field-types/supported-field-types/string.md Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> * Update _field-types/supported-field-types/constant-keyword.md Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> --------- Signed-off-by: Michael Froh Signed-off-by: Fanit Kolchina Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> Co-authored-by: Fanit Kolchina Co-authored-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> Co-authored-by: Nathan Bower --- .../supported-field-types/constant-keyword.md | 41 +++++++++++++++++++ _field-types/supported-field-types/string.md | 1 + 2 files changed, 42 insertions(+) create mode 100644 _field-types/supported-field-types/constant-keyword.md diff --git a/_field-types/supported-field-types/constant-keyword.md b/_field-types/supported-field-types/constant-keyword.md new file mode 100644 index 0000000000..b92e1fbbab --- /dev/null +++ b/_field-types/supported-field-types/constant-keyword.md @@ -0,0 +1,41 @@ +--- +layout: default +title: Constant keyword +nav_order: 71 +has_children: false +parent: String field types +grand_parent: Supported field types +--- + +# 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: + +```json +PUT romcom_movies +{ + "mappings" : { + "properties" : { + "genre" : { + "value" : "Romantic comedy" + } + } + } +} +``` +{% include copy-curl.html %} + +## 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. + diff --git a/_field-types/supported-field-types/string.md b/_field-types/supported-field-types/string.md index c891f86cf6..6552b4a35c 100644 --- a/_field-types/supported-field-types/string.md +++ b/_field-types/supported-field-types/string.md @@ -20,3 +20,4 @@ Field data type | Description [`text`]({{site.url}}{{site.baseurl}}/opensearch/supported-field-types/text/) | A string that is analyzed. Useful for full-text search. [`match_only_text`]({{site.url}}{{site.baseurl}}/field-types/supported-field-types/match-only-text/) | A space-optimized version of a `text` field. [`token_count`]({{site.url}}{{site.baseurl}}/opensearch/supported-field-types/token-count/) | Counts the number of tokens in a string. +[`constant_keyword`]({{site.url}}{{site.baseurl}}/field-types/supported-field-types/constant-keyword/) | Similar to `keyword` but uses a single value for all documents.