Open
Description
Our default dynamic mappings rules create both a text and a keyword field whenever they hit a JSON string:
{
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
And over the years, many clients implemented similar logic:
- when an exact query is fired, use the
keyword
field, - when an aggregation is used, use the
keyword
field, - otherwise use the
text
field.
Is it logic that we should embed in Elasticsearch? Maybe we can find better ideas, but here is a proposal to get the discussion started:
- Create a new
exact_match
query, which tries to match against the whole string. It fails fortext
fields and has the same behavior asmatch
onkeyword
, numbers, ... - Create a new
text_keyword
field, which is essentially a wrapper around atext
and akeyword
field. Running aggregations or anexact_match
query against this field use the subkeyword
field whilematch
,query_string
,multi_match
andsimple_query_string
queries use thetext
field. - Update default dynamic mappings to create this field for strings instead of the current
text
+ subkeyword
mapping.