1
votes

I want to re-index all documents in elasticsearch index. Delete by query(with match_all) seems too expensive operation, so i probably drop and create the index (and call PUT the mapping again) Is there any better approach?

1
@Aaronmins I dont need to save the old documnets.User1234
It's not about saving old documents, it's about using scroll to retrieve the documents from the old index and bulk to publish them to the new one. You said you needed to reindex all documents so I thought it would be relevant.Aaron

1 Answers

1
votes

In previous versions, you were able to delete the index mappings.

client.admin().indices().prepareDeleteMapping(indexKey)
    .setType(typeKey).execute().actionGet(); 

Unfortunately, since version 2.1 this is not possible anymore, and you should either delete everything one by one, or simply delete the whole index.

See https://www.elastic.co/guide/en/elasticsearch/reference/2.1/indices-delete-mapping.html