通过查询从Elasticsearch删除记录 [英] Delete records from Elasticsearch by query

查看:200
本文介绍了通过查询从Elasticsearch删除记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从Elasticsearch中删除特定的日期记录。我的查询如下:

  curl -XDELETE'http:// localhost:9200 / twitter / twit / _query'-d '
{
filter:{
range:{
date_time:{from:2012-10-01 00:00:01 to:2013-05-01 11:59:59}
}
}
}'

但它不是删除任何记录。所以它是正确的或有其他方法来删除记录。

解决方案

在1.0之前,查询删除使用过滤器。语法直接指向搜索API中的查询块。您需要使用范围查询

  curl -XDELETE'http:// localhost:9200 / twitter / twit / _query'-d'
{
range:{
date_time:{from:2012-10-01 00:00:01,to:2013-05-01 11:59:59}
}
}'


I am trying to delete specific date records from Elasticsearch. My query is the following:

curl -XDELETE 'http://localhost:9200/twitter/twit/_query' -d '
{
    "filter" : {
            "range" : {
                "date_time" : { "from" : "2012-10-01 00:00:01", "to" : "2013-05-01 11:59:59"}
            }
        }
}'

but it is not deleting any records. so it is correct one or are there some other methods to delete records.

解决方案

Prior to 1.0, the delete by query does not use filters. The syntax goes directly to what is the "query" block in the search API. You need to use the range query instead.

curl -XDELETE 'http://localhost:9200/twitter/twit/_query' -d '
{
    "range" : {
        "date_time" : { "from" : "2012-10-01 00:00:01", "to" : "2013-05-01 11:59:59"}
    }
}'

这篇关于通过查询从Elasticsearch删除记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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