Search code examples
elasticsearchreindex

How to really reindex data in elasticsearch


I have added new mappings (mainly not_analyzed versions of existing fields) I now have to figure out how to reindex the existing data. I have tried following the guide on elastic search website but that is just too confusing. I have also tried using plugins (elasticsearch-reindex, allegro/elasticsearch-reindex-tool). I have looked at ElasticSearch - Reindexing your data with zero downtime which is a similar question. I was hoping to not have to rely on external tools (if possible) and try and use bulk API (as with original insert)

I could easily rebuild the whole index as it's a read only data really but that wont really work in the long term if I should want to add more fields etc etc when I'm in production with it. I wondered if there was anyone who knows of an easy to understand/follow solution or steps for a relative novice to ES. I'm on version 2 and using Windows.


Solution

  • With version 2.3.4 a new api _reindex is available which will do exactly what it says. Basic usage is

    {
        "source": {
            "index": "currentIndex"
        },
        "dest": {
            "index": "newIndex"
        }
    }