在Elasticsearch中删除文档 [英] Delete the document in elasticsearch
本文介绍了在Elasticsearch中删除文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想通过时间戳和自定义字段"cu_hostname"之一删除elasticserach中的文档.我想删除特定时间戳记中所有值为"cu_hostname = abc"的文件
I want to delete the document in elasticserach by timestamp and one of the custom field "cu_hostname". I want to remove all the documents which are in the specific time stamp which have the value "cu_hostname=abc"
我写了一个时间戳查询,如下所示:
I have written a query for timestamp as below:
POST filebeat-perf-1/_delete_by_query
{
"query":{
"range": {
"@timestamp": {
"gte": "1510511400000",
"lte": "1510597799000"
}
}
}
}
并删除自定义字段:
curl -XPOST '10.193.104.42:9200/filebeat-perf-1/_delete_by_query?conflicts=proceed&pretty' -H 'Content-Type: application/json' -d'
{
"query": {
"wildcard": {
"cu_hostname": "abc"
}
}
}
如何结合这两个查询?
推荐答案
您只需要将它们与 bool/filter
查询结合在一起
You simply need to combine both with a bool/filter
query:
POST filebeat-perf-1/_delete_by_query
{
"query": {
"bool": {
"filter": [
{
"range": {
"@timestamp": {
"gte": "1510511400000",
"lte": "1510597799000"
}
}
},
{
"wildcard": {
"cu_hostname": "abc"
}
}
]
}
}
}
这篇关于在Elasticsearch中删除文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文