簡體   English   中英

Spring數據elasticsearch批量索引和刪除

[英]Spring data elasticsearch bulk index and delete

我是社區的新手,所以如果我做錯了什么,我深表歉意。

我正在使用 spring 數據 elasticsearch (2.0.4/2.4) 我想進行批量插入和刪除。 但是 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
        );
    }
}

所以我創建了一個批量方法來處理兩者,但我無法訪問私有方法 prepareIndex 。

您是否知道批量索引和刪除文檔的任何解決方案,或者我是否應該使用反射來更改 prepareIndex 方法的可見性,或者是否有任何簡單的方法可以從模型/POJO 創建 indexRequest?

不確定您指的是哪個版本

(2.0.4/2.4)

目前沒有批量刪除的可能性。 並且在一個請求中不能組合不同的操作,例如索引/更新。

您能否在 Jira 中提交問題以添加對批量刪除的支持以及在一次調用中進行不同操作的可能性? 雖然這不會進入下一個版本,但恐怕。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM