use of io.searchbox.core.Delete in project herd by FINRAOS.
the class IndexFunctionsDaoImpl method deleteIndexDocuments.
/**
* The delete index documents function will delete a list of document in the index by a list of document ids.
*/
@Override
public final void deleteIndexDocuments(String indexName, String documentType, List<Integer> ids) {
LOGGER.info("Deleting Elasticsearch documents from index, indexName={}, documentType={}, ids={}.", indexName, documentType, ids.stream().map(Object::toString).collect(Collectors.joining(",")));
List<String> allIndices = getAliases(indexName);
allIndices.forEach((index) -> {
// Prepare a bulk request builder
Bulk.Builder bulkBuilder = new Bulk.Builder();
// For each document prepare a delete request and add it to the bulk request builder
ids.forEach(id -> {
BulkableAction action = new Delete.Builder(id.toString()).index(index).type(documentType).build();
bulkBuilder.addAction(action);
});
JestResult jestResult = jestClientHelper.executeAction(bulkBuilder.build());
// If there are failures log them
if (!jestResult.isSucceeded()) {
LOGGER.error("Bulk response error = {}", jestResult.getErrorMessage());
}
});
}
use of io.searchbox.core.Delete in project dq-easy-cloud by dq-open-cloud.
the class TransportClient method deleteDocument.
/**
* 删除Document
*
* @throws Exception
*/
@Test
public void deleteDocument() throws Exception {
Delete delete = new Delete.Builder("").index(indexName).type(typeName).build();
JestResult result = jestClient.execute(delete);
System.out.println(result.getJsonString());
}
use of io.searchbox.core.Delete in project herd by FINRAOS.
the class IndexFunctionsDaoImpl method deleteDocumentById.
/**
* The delete document by id function will delete a document in the index by the document id.
*/
@Override
public final void deleteDocumentById(String indexName, String documentType, String id) {
LOGGER.info("Deleting Elasticsearch document from index, indexName={}, documentType={}, id={}.", indexName, documentType, id);
Action action = new Delete.Builder(id).index(indexName).type(documentType).build();
JestResult result = jestClientHelper.executeAction(action);
LOGGER.info("Deleting Elasticsearch document from index, indexName={}, documentType={}, id={} is successfully {}. ", indexName, documentType, id, result.isSucceeded());
}
Aggregations