ElasticSearch批量更新文档

/**
     * 批量更新文档
     *
     * @param index     ES索引
     * @param documents 待提交的批量文档
     * @param uuidKey   文档中ID字段对应的key值
     */
    public BulkResponse updateDocumentsAsBatch(String index, List<Map<String, Object>> documents, String uuidKey) {
        BulkResponse response = null;
        if (StringUtils.isBlank(index) || CollectionUtils.isEmpty(documents)) {
            log.warn("Es index is blank or documents is empty.");
            return response;
        }

        try {
            int size = documents.size();
            BulkRequest bulkRequest = new BulkRequest();
            for (int i = 0; i < size; i++) {
                Map<String, Object> document = documents.get(i);
                if (MapUtils.isEmpty(document) || !document.containsKey(uuidKey)) {
                    continue;
                }
                bulkRequest.add(new UpdateRequest(index, document.get(uuidKey).toString()).doc(document));
            }
            response = client.bulk(bulkRequest, RequestOptions.DEFAULT);
        } catch (Exception e) {
            log.error("Update documents to es as batch failed!", e);
        }
        return response;
    }