【问题标题】:Elasticsearch delete-by-query returns success but records persist?Elasticsearch delete-by-query 返回成功但记录仍然存在?
【发布时间】:2013-04-27 04:52:46
【问题描述】:

我正在尝试使用 delete by query API 从 elasticsearch 中删除记录

执行:

curl -XDELETE localhost:4040/search/foo/_query -d '{
  "term": {
    "record id": "0f9eaa6f-90bb-4dee-9ecb-78a5d04719c0"
  }
}'

结果:

{
  "ok": true,
  "_indices": {
    "foo": {
      "_shards": {
        "total": 5,
        "successful": 5,
        "failed": 0
      }
    }
  }
}

但是,查询:

curl -XGET localhost:4040/search/foo/_search -d '{
  "query": {
    "match": {
      "record id": "0f9eaa6f-90bb-4dee-9ecb-78a5d04719c0"
    }
  }
}'

给我:

{
  "took": 2,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  }
}

打印了 5 条记录...

我试过跑步:

curl -XGET localhost:4040/search/foo/_refresh

但仍然返回结果?

【问题讨论】:

    标签: json rest lucene elasticsearch


    【解决方案1】:

    您正在使用term 查询进行删除,并且您正在使用match 查询进行搜索。这是两个不同的查询。 term 查询不会分析提供的查询词,而 match 会。因此,这两个查询可能会产生不同的结果,具体取决于您的 record id 字段的分析方式。

    【讨论】:

    • 谢谢。我需要的是: curl -XDELETE localhost:4040/search/foo/bar/_query -d '{"match" : {"record id" : "0f9eaa6f-90bb-4dee-9ecb-78a5d04719c0"}}'
    猜你喜欢
    • 2020-12-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-01
    • 2020-02-04
    • 2020-03-09
    • 2019-03-04
    相关资源
    最近更新 更多