繁体   English   中英

Elasticsearch DeleteByQuery无法正常工作,收到400错误请求

[英]Elasticsearch DeleteByQuery not working, getting 400 bad request

我有以下Nest查询来删除所有匹配的文档,很简单,但是我收到了400个错误的请求。

 var client = new ElasticClient();
        var request = new DeleteByQueryRequest<Type>("my-index")
        {
            Query = new QueryContainer(
                    new TermQuery
                    {
                        Field = "versionId",
                        Value = "ea8e517b-c2e3-4dfe-8e49-edc8bda67bad"
                    }
                )
        };
        var response = client.DeleteByQuery(request);
        Assert.IsTrue(response.IsValid);

谢谢你的帮助。

---------------更新---------------

请求正文

{"query":{"term":{"versionId":{"value":"ea8e517b-c2e3-4dfe-8e49-edc8bda67bad"}}}}

反应体

{"took":0,"timed_out":false,"_indices":{"_all":{"found":0,"deleted":0,"missing":0,"failed":0}},"failures":[]}

在Sense插件中查询:

GET /my-index/type/_search
{
  "query": {

          "match": {
             "versionId": "ea8e517b-c2e3-4dfe-8e49-edc8bda67bad"
          } 

  }
}

查询响应:

{
   "took": 3,
   "timed_out": false,
   "_shards": {
      "total": 5,
      "successful": 5,
      "failed": 0
   },
   "hits": {
      "total": 116,
      "max_score": 2.1220484,
      "hits": []
...
}}

---------------嵌套查询--------------

DELETE http://localhost:9200/my-index/component/_query?pretty=true
{
  "query": {
    "term": {
      "versionId": {
        "value": "ea8e517b-c2e3-4dfe-8e49-edc8bda67bad"
      }
    }
  }
}

Status: 200
{
  "took" : 0,
  "timed_out" : false,
  "_indices" : {
    "_all" : {
      "found" : 0,
      "deleted" : 0,
      "missing" : 0,
      "failed" : 0
    }
  },
  "failures" : [ ]
}

听起来您可能正在将Elasticsearch 2.x与NEST 2.x结合使用。 作为Elasticsearch 2.0的一部分,“ 按查询删除”已移出Elasticsearch核心,并移至需要安装的单独插件中。 您可以在Elasticsearch bin目录中使用以下命令安装插件

bin/plugin install delete-by-query

再次启动节点,按查询删除现在应该可以正常工作。

如果您需要获取有关请求失败原因的更多详细信息,则可以检查响应中的.DebugInformation以获取该请求的审核跟踪。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM