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
textfield, with akeywordsub-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.keywordfield.If you want it to be mapped as a
keywordyou will have to specify your own explicit mappings.