It's not possible without reindexing. You can "upgrade" the field to have a multi-field (raw in this case), but all existing documents will have an empty name.raw as you discovered.
You'll have to index the docs again or use the reindex API.
This is done to make the cost explicit; imagine you have a petabyte of data and update the mapping to include a new mapping. If we auto-reindexed the field, there'd a petabyte of background reindexing that would get kicked off, and all sorts of dangerous edge-cases could pop up (what if the user changes it again during the process? What if the cluster crashes? etc etc).
Thank you.
And could you confirm me that this multi-field does not take any place in the source?
"Ted" would not be indexed twice as a name and a name.raw ?
Correct. Elasticsearch never alters the original JSON source, so what you send is what you get back in _source.
Mostly a confusion of terms, but technically "Ted" will be indexed twice. When you add a multifield, what you're doing is telling Elasticsearch to index the field different ways, using different analyzers. So the value will be added into an inverted index for each extra multi-field that you add.
It'll still only show up once in the _source, but internally it will be indexed multiple times to support the multi-field.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.