使用JEST通过查询删除ElasticSearch [英] Delete ElasticSearch by Query with JEST
问题描述
我的ElasticSearch中有一些自定义数据(我们叫相机),在Kibana中显示的数据就像
I have some custom data(let's call Camera) in my ElasticSearch, the data showed in Kibana is like
然后我尝试根据本文 ElasticSearch所接受的答案通过Query删除数据通过查询删除,我的代码就像
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);
结果为 404未找到.
很明显,ElasticSearch中存在一个相机数据,其中名称与查询匹配,因此我认为 404 是由其他原因引起的
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?
推荐答案
查询必须是真实查询,而不是部分文档
The query needs to be a real query, not a partial document
尝试与此
String query = "{\"query\": { \"match\": {\"Name\":\"test Added into Es\"}}}";
这篇关于使用JEST通过查询删除ElasticSearch的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!