ElasticSearch and NEST: How do you purge all documents from an index?

后端 未结 4 771
无人及你
无人及你 2021-01-07 23:06

I know how to delete an entire ElasticSearch index, but how do you purge all documents from an index?

My Motivation: I\'d like to have a \"ReIndex\" method that purg

4条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-07 23:14

    You can use a delete by query. This will delete all documents that match * i.e. everything.

    curl -XDELETE localhost:9200//_query?q=*
    
    • Change localhost to the hostname that node is running on.

    http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-delete-by-query.html

    Don't forget to optimize afterwards.

    curl localhost:9200//_optimize
    

提交回复
热议问题