Delete documents of type in Elasticsearch

前端 未结 7 1636
南旧
南旧 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:20

    If you want to do this in golang, using the "olviere/elastic" library, you can use this code, assuming you have a client yourClient, and yourIndex and yourType:

        bq := elastic.NewBoolQuery()
        bq.Must(elastic.NewMatchAllQuery())
        _, err := elastic.NewDeleteByQueryService(yourClient).
            Index(yourIndex).
            Type(yourType).
            Query(bq).
            Do()
    

提交回复
热议问题