Delete ElasticSearch by Query with JEST

一笑奈何 提交于 2019-12-11 05:30:50

问题


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

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:


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\"}}}";


来源:https://stackoverflow.com/questions/44324013/delete-elasticsearch-by-query-with-jest

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!