Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation for constant_keyword field type #7235

Merged
merged 7 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions _field-types/supported-field-types/constant-keyword.md
Original file line number Diff line number Diff line change
@@ -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"
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example does not work. The "type" field is missing. It must look something like this:

... "genre" : { "type": "constant_keyword", "value" : "Romantic comedy" } ...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @mrpi! Corrected the example in #7256

}
}
}
```
{% 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 value for the field for all documents in the index.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"string value for the field" => "field string value"?

kolchfa-aws marked this conversation as resolved.
Show resolved Hide resolved

1 change: 1 addition & 0 deletions _field-types/supported-field-types/string.md
Original file line number Diff line number Diff line change
Expand Up @@ -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}}/opensearch/supported-field-types/constant-keyword/) | Similar to `keyword` but uses a single value for all documents.
kolchfa-aws marked this conversation as resolved.
Show resolved Hide resolved
Loading