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 do I use an elasticsearch query builder?
- How can I use Elasticsearch and ZFS together?
- How can I use Yandex Mirror to access Elasticsearch data?
- How can I use Elasticsearch and Zookeeper together to manage distributed applications?
- How can I use Elasticsearch to diagnose "yellow" issues?
- How can I use Elasticsearch and Zabbix together for software development?
- How do I set up an Elasticsearch Yum repository?
- How can I use YouTube to learn about Elasticsearch?
- How can I use elasticsearch zone awareness to improve my software development?
- How do I configure elasticsearch to use an XMS memory allocator?
See more codes...