Elasticsearch DeleteByQuery not working, receiving 400 bad queries

I have the following Nest request to delete all relevant documents, quite simply, but I get 400 bad requests.

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); 

Thanks for any help.

--------------- Update ---------------

Request body

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

Reaction body

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

Query in Sense Plugin:

 GET /my-index/type/_search { "query": { "match": { "versionId": "ea8e517b-c2e3-4dfe-8e49-edc8bda67bad" } } } 

Response to the request:

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

--------------- NEST QUERY --------------

 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" : [ ] } 
+8
c # elasticsearch nest
source share
1 answer

It looks like you can use Elasticsearch 2.x along with NEST 2.x. As part of Elasticsearch 2.0, Uninstall on Demand has been removed from the Elasticsearch core and into a separate plugin that needs to be installed. You can install the plugin using the following command in the Elasticsearch Recycle Bin directory

 bin/plugin install delete-by-query 

By running node again, β€œDelete on Demand” will now work as expected.

If you ever need to get more information about why the request failed, you can check .DebugInformation for an answer to get the audit trail for the request.

+5
source share

All Articles