Delete documents of type in Elasticsearch

前端 未结 7 1440
南旧
南旧 2021-02-18 16:50

I want to delete all the documents indexed within a type in Elasticsearch, using the HTTP/REST api, but I don\'t want to delete the mapping for this type

How can I build

7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-18 17:27

    A simple delete by query with a match_all query should do the trick. You can grab more info here :

    delete by query api

    Alternatively, you can delete the whole type and make use of the template api. Just drop a file in your config/templates/ folder containing your template, and you'll never loose it. The mapping will indeed be lost when you'll delete the mapping, but the template will be reused as soon as you index something again. Here's some more info :

    template api

    EDIT: new delete api: https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete.html

提交回复
热议问题