Elasticsearch使用搜索查询删除结果

时间:2012-11-12 21:58:01

标签: curl elasticsearch dsl

以下是布尔搜索查询。我想删除此查询匹配的所有文档结果。怎么做?

我尝试delete by query interface(新api是here

CURL -XDELETE /index/doc/_query/routing=abc -d '{
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "_ua_family": "Firefox"
          }
        },
        {
          "range": {
            "created_at": {
              "gte": 1352147225,
              "lte": 1352752025
            }
          }
        }
      ],
      "should": [],
      "must_not": []
    }
  },
  "sort": {
    "created_at": "desc"
  },
  "facets": {
    "_message": {
      "histogram": {
        "field": "created_at",
        "interval": 3600
      }
    }
  },
  "from": 0,
  "size": 10
}'

elasticsearch response contains

{
  "_shards": {
    "total": 1,
    "successful": 0,
    "failed": 1
  }
}

1 个答案:

答案 0 :(得分:2)

搞定了,查询应该是

{
    "bool": {
        "must": [{
            "term": {
                "_ua_family": "Firefox"
            }
        }, {
            "range": {
                "created_at": {
                    "gte": 1352147225,
                    "lte": 1352752025
                }
            }
        }],
        "should": [],
        "must_not": []
    }
}
相关问题