My painless script for a re-index is adding a field. How can I index that new field as a keyword
vice text field using painless?
POST _reindex
{
8<
"script" : {
"source" : "ctx._source.newfield = 'test'"
"lang" : "painless"
}
I want newfield
to be newfield.keyword
By default, Elasticsearch will map it to a
text
field, with akeyword
sub-field, unless you have specified explicit mapping. Your mapping would look like this:As a consequence, it will both be possible to perform full-text search on
newfield
, and keyword search and aggregations using thenewfield.keyword
field.If you want it to be mapped as a
keyword
you will have to specify your own explicit mappings.