Alanight
Alanight

Reputation: 361

Delete ElasticSearch by Query with JEST

I have some custom data(let's call Camera) in my ElasticSearch, the data showed in Kibana is like

enter image description here

And I tried to delete data by Query according to the accepted answer in this article ElasticSearch Delete by Query, my code is like

String query = "{\"Name\":\"test Added into Es\"}";
DeleteByQuery delete = new DeleteByQuery.Builder(query).addIndex(this._IndexName).addType(this._TypeName).build();

JestResult deleteResult = this._JestClient.execute(delete);

And the result is 404 Not Found.

Its obvious that there exist one Camera data in ElasticSearch which Name match the query, so I believe the 404 is caused by other reason.

Did I do anything wrong? Should I change the query string?

Upvotes: 1

Views: 887

Answers (1)

Val
Val

Reputation: 217274

The query needs to be a real query, not a partial document

Try with this instead

String query = "{\"query\": { \"match\": {\"Name\":\"test Added into Es\"}}}";

Upvotes: 1

Related Questions