我不小心从Logstash加载了一些数据到Elasticsearch中。
基本上,我忘了包括start_position => "beginning"
在Logstash配置中,因此,如果我删除.sincedb_*
并重新运行,将会有一小部分数据被重复。
我已经使用Kibana来查看此数据,然后单击“检查”按钮以查看其运行的查询:
curl -XGET 'http://els-server:9200/logstash-2014.02.19,logstash-2014.02.18/_search?pretty' -d '{
"facets": {
"0": {
"date_histogram": {
"field": "@timestamp",
"interval": "10m"
},
"facet_filter": {
"fquery": {
"query": {
"filtered": {
"query": {
"query_string": {
"query": "tags:\"a-tag-that-uniquely-matches-the-mistake\""
}
},
"filter": {
"bool": {
"must": [
{
"match_all": {}
},
{
"range": {
"@timestamp": {
"from": 1392723206360,
"to": "now"
}
}
},
{
"bool": {
"must": [
{
"match_all": {}
}
]
}
}
]
}
}
}
}
}
}
}
},
"size": 0
}'
如果我在ELS服务器上运行此命令,它将找到相同的结果集(如预期的那样):
{
"took" : 23,
"timed_out" : false,
"_shards" : {
"total" : 10,
"successful" : 10,
"failed" : 0
},
"hits" : {
"total" : 558829,
"max_score" : 0.0,
"hits" : [ ]
},
"facets" : {
"0" : {
"_type" : "date_histogram",
"entries" : [ {
"time" : 1392799200000,
"count" : 91
} ]
}
}
}
该行"count" : 91
与Kibana中显示的事件数相同。
如何将其转换为DELETE操作以删除这91个条目?
谢谢,
KB
我相信您可以在1.0或更高版本中通过查询删除。
我使用Chrome插件Sense来针对ES手动运行查询。
例子:
DELETE /twitter/tweet/_query
{
"query" : {
"term" : { "user" : "kimchy" }
}
}
在您的情况下,您应该只使用查询的查询部分:
DELETE /twitter/_search
{
"query": {
"filtered": {
"query": {
"query_string": {
"query": "tags:\"a-tag-that-uniquely-matches-the-mistake\""
}
},
"filter": {
"bool": {
"must": [
{
"match_all": {}
},
{
"range": {
"@timestamp": {
"from": 1392723206360,
"to": "now"
}
}
},
{
"bool": {
"must": [
{
"match_all": {}
}
]
}
}
]
}
}
}
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句