protected DeleteRequestBuilder prepareDeleteRequest(final String index, final String documentId, final String documentType) { return esClient.get().prepareDelete(index, documentType, documentId); }
@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 ); } }
/** * 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(); }
/** * 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; } }
/** * 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); }
public void delete(Long id) { this.bulkRequest.add(this.esClient.prepareDelete("photon", "place", String.valueOf(id))); }
@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(); }
/** * 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; }
@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; }
@Override public String delete(String indexName, String type, String id) { return client.prepareDelete(indexName, type, id) .execute().actionGet().getId(); }
@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(); }
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()); } }
@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(); }
@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(); }
@Override public void deleteProduct(ElasticSearchIndexConfig config, Long productId) { searchClientService.getClient().prepareDelete(config.getIndexAliasName(), config.getDocumentType(), String.valueOf(productId)).get(); }
public void deleteDocument(String indexName, String type, String id) { client.prepareDelete() .setIndex(indexName) .setType(type) .setId(id) .execute().actionGet(); }
@Override public void deleteProduct(final ElasticSearchIndexConfig config, final Long productId) { searchClientService .getClient() .prepareDelete(config.getIndexAliasName(), config.getDocumentType(), String.valueOf(productId)) .get(); }
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++; }
@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); }
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(); }