本文整理了Java中org.elasticsearch.client.Client.prepareDelete()
方法的一些代码示例,展示了Client.prepareDelete()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Client.prepareDelete()
方法的具体详情如下:
包路径:org.elasticsearch.client.Client
类名称:Client
方法名:prepareDelete
[英]Deletes a document from the index based on the index, type and id.
[中]根据索引、类型和id从索引中删除文档。
代码示例来源:origin: apache/nifi
protected DeleteRequestBuilder prepareDeleteRequest(final String index, final String documentId, final String documentType) {
return esClient.get().prepareDelete(index, documentType, documentId);
}
代码示例来源:origin: apache/usergrid
@Override
public void doOperation( final Client client, final BulkRequestBuilder bulkRequest ) {
for ( final String index : indexes ) {
final DeleteRequestBuilder builder =
client.prepareDelete( index, IndexingUtils.ES_ENTITY_TYPE, documentId );
bulkRequest.add( builder );
}
}
代码示例来源:origin: loklak/loklak_server
/**
* Delete a document for a given id.
* ATTENTION: deleted documents cannot be re-inserted again if version number
* checking is used and the new document does not comply to the version number
* rule. The information which document was deleted persists for one minute and
* then inserting documents with the same version number as before is possible.
* To modify this behavior, change the configuration setting index.gc_deletes
*
* @param id
* the unique identifier of a document
* @return true if the document existed and was deleted, false otherwise
*/
public boolean delete(String indexName, String typeName, final String id) {
return elasticsearchClient.prepareDelete(indexName, typeName, id).execute().actionGet().isFound();
}
代码示例来源:origin: brianfrankcooper/YCSB
/**
* Delete a record from the database.
*
* @param table
* The name of the table
* @param key
* The record key of the record to delete.
* @return Zero on success, a non-zero error code on error. See this class's
* description for a discussion of error codes.
*/
@Override
public Status delete(String table, String key) {
try {
DeleteResponse response = client.prepareDelete(indexKey, table, key).execute().actionGet();
if (response.isFound()) {
return Status.OK;
} else {
return Status.NOT_FOUND;
}
} catch (Exception e) {
e.printStackTrace();
return Status.ERROR;
}
}
代码示例来源:origin: apache/usergrid
/**
* Tests writing a document to a new index to ensure it's working correctly. See this post:
* http://s.apache.org/index-missing-exception
*/
private void testNewIndex() {
// create the document, this ensures the index is ready
// Immediately create a document and remove it to ensure the entire cluster is ready
// to receive documents. Occasionally we see errors.
// See this post: http://s.apache.org/index-missing-exception
if (logger.isTraceEnabled()) {
logger.trace("Testing new index name: read {} write {}", alias.getReadAlias(), alias.getWriteAlias());
}
final RetryOperation retryOperation = () -> {
final String tempId = UUIDGenerator.newTimeUUID().toString();
esProvider.getClient().prepareIndex( alias.getWriteAlias(), VERIFY_TYPE, tempId )
.setSource(DEFAULT_PAYLOAD).get();
if (logger.isTraceEnabled()) {
logger.trace("Successfully created new document with docId {} in index read {} write {} and type {}",
tempId, alias.getReadAlias(), alias.getWriteAlias(), VERIFY_TYPE);
}
// delete all types, this way if we miss one it will get cleaned up
esProvider.getClient().prepareDelete( alias.getWriteAlias(), VERIFY_TYPE, tempId).get();
if (logger.isTraceEnabled()) {
logger.trace("Successfully deleted documents in read {} write {} and type {} with id {}",
alias.getReadAlias(), alias.getWriteAlias(), VERIFY_TYPE, tempId);
}
return true;
};
doInRetry(retryOperation);
}
代码示例来源:origin: komoot/photon
public void delete(Long id) {
this.bulkRequest.add(this.esClient.prepareDelete("photon", "place", String.valueOf(id)));
}
代码示例来源:origin: Impetus/Kundera
@Override
public void unIndex(Class entityClazz, Object entity, EntityMetadata metadata, MetamodelImpl metamodelImpl)
{
Object id = PropertyAccessorHelper.getId(entity, metadata);
DeleteResponse response = client
.prepareDelete(metadata.getSchema().toLowerCase(), entityClazz.getSimpleName(), id.toString()).execute()
.actionGet();
}
代码示例来源:origin: yacy/yacy_grid_mcp
/**
* Delete a document for a given id.
* ATTENTION: deleted documents cannot be re-inserted again if version number
* checking is used and the new document does not comply to the version number
* rule. The information which document was deleted persists for one minute and
* then inserting documents with the same version number as before is possible.
* To modify this behavior, change the configuration setting index.gc_deletes
*
* @param id
* the unique identifier of a document
* @return true if the document existed and was deleted, false otherwise
*/
public boolean delete(String indexName, String typeName, final String id) {
DeleteResponse response = elasticsearchClient.prepareDelete(indexName, typeName, id).get();
return response.getResult() == DocWriteResponse.Result.DELETED;
}
代码示例来源:origin: ujmp/universal-java-matrix-package
@Override
protected MapMatrix<String, Object> removeFromMap(Object key) {
MapMatrix<String, Object> old = get(key);
client.prepareDelete(index, type, String.valueOf(key)).execute().actionGet();
return old;
}
代码示例来源:origin: SpringDataElasticsearchDevs/spring-data-elasticsearch
@Override
public String delete(String indexName, String type, String id) {
return client.prepareDelete(indexName, type, id)
.execute().actionGet().getId();
}
代码示例来源:origin: com.impetus.client/kundera-elastic-search
@Override
public void unIndex(Class entityClazz, Object entity)
{
EntityMetadata metadata = KunderaMetadataManager.getEntityMetadata(entityClazz);
Object id = PropertyAccessorHelper.getId(entity, metadata);
DeleteResponse response = client
.prepareDelete(metadata.getSchema().toLowerCase(), entityClazz.getSimpleName(), id.toString())
.execute().actionGet();
}
代码示例来源:origin: Findwise/Hydra
private void delete(LocalDocument document) {
String docId = getDocumentId(document);
ListenableActionFuture<DeleteResponse> actionFuture = client.prepareDelete(documentIndex, documentType, docId)
.execute();
DeleteResponse response = actionFuture.actionGet(requestTimeout);
if (response.isNotFound()) {
logger.debug("Delete failed, document not found");
}
else {
logger.debug("Deleted document with id " + response.getId());
}
}
代码示例来源:origin: org.vertexium/vertexium-elasticsearch2
@Override
public void deleteExtendedData(Graph graph, ExtendedDataRowId rowId, Authorizations authorizations) {
String indexName = getExtendedDataIndexName(rowId);
String docId = ElasticsearchExtendedDataIdUtils.toDocId(rowId);
getClient().prepareDelete(indexName, ELEMENT_TYPE, docId).execute().actionGet();
}
代码示例来源:origin: org.vertexium/vertexium-elasticsearch-singledocument
@Override
public void deleteExtendedData(Graph graph, ExtendedDataRowId rowId, Authorizations authorizations) {
String indexName = getExtendedDataIndexName(rowId);
String docId = ElasticsearchExtendedDataIdUtils.toDocId(rowId);
getClient().prepareDelete(indexName, ELEMENT_TYPE, docId).execute().actionGet();
}
代码示例来源:origin: jaibeermalik/elasticsearch-tutorial
@Override
public void deleteProduct(ElasticSearchIndexConfig config, Long productId)
{
searchClientService.getClient().prepareDelete(config.getIndexAliasName(), config.getDocumentType(), String.valueOf(productId)).get();
}
代码示例来源:origin: ncolomer/elasticsearch-osmosis-plugin
public void deleteDocument(String indexName, String type, String id) {
client.prepareDelete()
.setIndex(indexName)
.setType(type)
.setId(id)
.execute().actionGet();
}
代码示例来源:origin: jaibeermalik/searchanalytics-bigdata
@Override
public void deleteProduct(final ElasticSearchIndexConfig config,
final Long productId) {
searchClientService
.getClient()
.prepareDelete(config.getIndexAliasName(),
config.getDocumentType(), String.valueOf(productId))
.get();
}
代码示例来源:origin: rmagen/elastic-gremlin
public void deleteElement(Element element, String index, String routing) {
DeleteRequestBuilder deleteRequestBuilder = client.prepareDelete(index, element.label(), element.id().toString()).setRouting(routing);
if(bulkRequest != null) bulkRequest.add(deleteRequestBuilder);
else deleteRequestBuilder.execute().actionGet();
revision++;
}
代码示例来源:origin: com.jeromeloisel/db-scroll-elastic
@Override
public void accept(final SearchHit hit) {
final DeleteRequest delete = client
.prepareDelete()
.setIndex(hit.getIndex())
.setType(hit.getType())
.setId(hit.getId())
.request();
request.get().add(delete);
}
代码示例来源:origin: org.apache.james/apache-james-backends-es
private ListenableActionFuture<BulkResponse> deleteRetrievedIds(Client client, SearchResponse searchResponse) {
BulkRequestBuilder bulkRequestBuilder = client.prepareBulk();
for (SearchHit hit : searchResponse.getHits()) {
bulkRequestBuilder.add(client.prepareDelete()
.setIndex(aliasName.getValue())
.setType(typeName.getValue())
.setId(hit.getId()));
}
return bulkRequestBuilder.execute();
}
内容来源于网络,如有侵权,请联系作者删除!