1

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?

1 Answer 1

1

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\"}}}";
Sign up to request clarification or add additional context in comments.

5 Comments

Can you share the full error please? and also which version of ES you're using
Sure! The full content is this {"found":false,"_index":"cameras","_type":"camera","_id":"_query","_version":1,"result":"not_found","_shards":{"total":2,"successful":1,"failed":0}}. And I'm using ElasticSearch 5.4.0.
Ok I see the problem. Jest uses the _query endpoint which was the endpoint used by the Delete by query plugin back in ES 2.x. From ES 5 onwards, the delete by query feature has made it into the core and the endpoint is now named _delete_by_query. That change has been made recently in Jest and will soon be released
So you have a few options: 1) downgrade to ES 2.4, 2) wait until the new Jest gets released or 3) checkout the Jest master branch and build it yourself.
Sorry for responding so lately... I didn't search afterwards, because building it by myself is quite impossible for me to achieve, and also I transfer my work on another part, so I didn't work on this issue anymore. But still very appreciate for your information and suggestions, hope there would be a way to solve(hopefully provided by JEST) afterwards. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.