[英]Spring data elasticsearch bulk index and delete
I'm new to the community so I apologise if I do something wrong.我是社区的新手,所以如果我做错了什么,我深表歉意。
I'm using spring data elasticsearch (2.0.4/2.4) And I would like to make a bulk insert and delete.我正在使用 spring 数据 elasticsearch (2.0.4/2.4) 我想进行批量插入和删除。 But ElasticsearchTemplate only contains a method bulkInsert
但是 ElasticsearchTemplate 只包含一个方法 bulkInsert
@Override
public void bulkIndex(List<IndexQuery> queries) {
BulkRequestBuilder bulkRequest = client.prepareBulk();
for (IndexQuery query : queries) {
bulkRequest.add(prepareIndex(query));
}
BulkResponse bulkResponse = bulkRequest.execute().actionGet();
if (bulkResponse.hasFailures()) {
Map<String, String> failedDocuments = new HashMap<String, String>();
for (BulkItemResponse item : bulkResponse.getItems()) {
if (item.isFailed())
failedDocuments.put(item.getId(), item.getFailureMessage());
}
throw new ElasticsearchException(
"Bulk indexing has failures. Use ElasticsearchException.getFailedDocuments() for detailed messages ["
+ failedDocuments + "]", failedDocuments
);
}
}
So I have created a bulk method to handle both but I can't access the method prepareIndex which is private.所以我创建了一个批量方法来处理两者,但我无法访问私有方法 prepareIndex 。
Are you aware of any solution to, in one bulk, index and delete documents or should I use reflection to change visibility of the prepareIndex method or is there any easy way to create an indexRequest from a model/POJO?您是否知道批量索引和删除文档的任何解决方案,或者我是否应该使用反射来更改 prepareIndex 方法的可见性,或者是否有任何简单的方法可以从模型/POJO 创建 indexRequest?
Not sure which versions you mean with不确定您指的是哪个版本
(2.0.4/2.4)
(2.0.4/2.4)
Currently there is no possibility for bulk deletes.目前没有批量删除的可能性。 And no combination of different operations like index/update in one request.
并且在一个请求中不能组合不同的操作,例如索引/更新。
Can you file an issue in Jira to add support for bulk delete and a possibility to have different operations in one call?您能否在 Jira 中提交问题以添加对批量删除的支持以及在一次调用中进行不同操作的可能性? Though this won't make it into the next release, I'm afraid.
虽然这不会进入下一个版本,但恐怕。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.