Delete all documents from index/type without deleting type

后端 未结 15 522
耶瑟儿~
耶瑟儿~ 2020-12-04 09:45

I know one can delete all documents from a certain type via deleteByQuery.

Example:

curl -XDELETE \'http://localhost:9200/twitter/tweet/_query\' -d \         


        
15条回答
  •  甜味超标
    2020-12-04 10:19

    You have these alternatives:

    1) Delete a whole index:

    curl -XDELETE 'http://localhost:9200/indexName'             
    

    example:

    curl -XDELETE 'http://localhost:9200/mentorz'
    

    For more details you can find here -https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-delete-index.html

    2) Delete by Query to those that match:

    curl -XDELETE 'http://localhost:9200/mentorz/users/_query' -d                
        '{
            "query":
                {
                    "match_all": {}
                }
        }'
    

    *Here mentorz is an index name and users is a type

提交回复
热议问题