0

Is it possible to update a mapping data type of a field in a document in elasticsearch? Do I have to drop the whole index and add a create a new one with the new mappings and all the documents to it again or is it possible to change the mapping and ask elasticsearch to reindex all documents with new mapping properties? The second way I dont lose all the documents.

Elasticsearch version : 6.3.2

humbleCoder
  • 667
  • 14
  • 27

1 Answers1

2

You have to reindex your data after you have changed the mapping. This is not only an issue of elasticsesrch, but applies to databases in general.

The best solution is to create a new index.

René Winkler
  • 6,508
  • 7
  • 42
  • 69
  • 2
    There are very few changes you can apply to an existing mapping, see my link in the comments above. So usually you need to create a new index with the new mapping and then reindex the old index into the new one. – Val Aug 02 '18 at 06:16
  • ok and the reindexing has to be done according to this right https://www.elastic.co/guide/en/elasticsearch/reference/6.3/docs-reindex.html ? So I create a new index with the new mappings and then use reindex to copy the old index into the new index? – humbleCoder Aug 02 '18 at 06:43
  • 1
    That is correct. You should use elasticsearh aliases to avoid downtime. That is a practice we do at my work all the time. – Remot Aug 02 '18 at 07:03