从索引/类型中删除所有文档而不删除类型 [英] Delete all documents from index/type without deleting type

查看:39
本文介绍了从索引/类型中删除所有文档而不删除类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道可以通过 deleteByQuery 删除某一类型的所有文档.

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

示例:

curl -XDELETE 'http://localhost:9200/twitter/tweet/_query' -d '{
    "query" : {
        "term" : { "user" : "kimchy" }
    }
}'

但我没有术语,只想删除该类型的所有文档,无论是什么术语.实现这一目标的最佳实践是什么?空术语不起作用.

But i have NO term and simply want to delete all documents from that type, no matter what term. What is best practice to achieve this? Empty term does not work.

deleteByQuery 链接

推荐答案

我相信,如果您将按查询删除与匹配项结合起来,它应该可以满足您的要求,例如(使用您的示例):

I believe if you combine the delete by query with a match all it should do what you are looking for, something like this (using your example):

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

或者你可以直接删除类型:

Or you could just delete the type:

curl -XDELETE http://localhost:9200/twitter/tweet

注意:XDELETE 在 ElasticSearch 的更高版本中被弃用

Note: XDELETE is deprecated for later versions of ElasticSearch

这篇关于从索引/类型中删除所有文档而不删除类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆