Home > database >  What happens to the data in the original index after reindexing in elasticsearch?
What happens to the data in the original index after reindexing in elasticsearch?

Time:12-01

In an elasticsearch instance, I have data in an index "a". I want to copy all data within a period (say Aug 2021 to September 2021) to another index "b". I apply reindex in the following manner:

POST _reindex
{
    "source": {
        "index": "a",
            "query": {
                    "range": {
                        "created": {
                            "gte": "2021-08-01 00:00:00.000",
                            "lt": "2021-09-01 00:00:00.000"
                            }
                        }
                    }
        },
    "dest": {
            "index": "b"
        }  
}

Now, if I decide to delete the index "b", what happens to the data that I just moved? Does it still stay in index "a"?

CodePudding user response:

Yes, the reindex operation leaves the source index untouched. After the reindex is done, you have two indexes a and b and you can decide to do whatever you want with them.

If you're happy with the data in index b you can decide to remove index a, if you're not, you can delete b, keep a and re-attempt another reindex.

It's up to you to do whatever you want.

  • Related