elasticsearchHow can I clear an elasticsearch index?
-
To clear an Elasticsearch index, use the
DELETE
request to delete the index.DELETE /<index_name>
This will delete the index and all of its documents.
-
To delete all the documents in the index without deleting the index itself, use the
DELETE
request with the_doc
endpoint.DELETE /<index_name>/_doc
This will delete all documents in the index but the index itself will remain.
-
To delete documents that match a certain criteria, use the
DELETE
request with the_delete_by_query
endpoint.DELETE /<index_name>/_delete_by_query { "query": { "match": { "field_name": "field_value" } } }
This will delete all documents that match the query criteria, but the index itself will remain.
-
To delete documents in bulk, use the
DELETE
request with the_bulk
endpoint.DELETE /<index_name>/_bulk { "delete" : { "_id" : "1" } } { "delete" : { "_id" : "2" } } { "delete" : { "_id" : "3" } }
This will delete the specified documents in bulk, but the index itself will remain.
-
To delete all documents in an index and recreate the index, use the
DELETE
request with the_all
endpoint.DELETE /_all
This will delete all documents in the index and recreate the index.
-
To delete an index, use the
DELETE
request to delete the index.DELETE /<index_name>
This will delete the index and all of its documents.
-
To delete an index permanently, use the
DELETE
request with the_force
endpoint.DELETE /<index_name>/_force
This will delete the index and all of its documents permanently, and the index cannot be recovered.
Relevant Links
More of Elasticsearch
- How can I use Elasticsearch with Zammad?
- How can I use Yandex Mirror to access Elasticsearch data?
- How do I configure elasticsearch to use an XMS memory allocator?
- How do I set up an Elasticsearch Yum repository?
- How can I use elasticsearch zone awareness to improve my software development?
- How can I use Elasticsearch and Zookeeper together to manage distributed applications?
- How can I check the status of a yellow index in Elasticsearch?
- How do I use Elasticsearch with ZGC?
- How do I use ElasticSearch to zip files?
- How can I use Elasticsearch and ZFS together?
See more codes...