User1234
User1234

Reputation: 511

java Elasticsearch delete all documens

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?

Upvotes: 1

Views: 532

Answers (1)

Romain VDK
Romain VDK

Reputation: 1896

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

Upvotes: 1

Related Questions