org.elasticsearch.action.delete.DeleteResponse Java Examples
The following examples show how to use
org.elasticsearch.action.delete.DeleteResponse.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CheckpointDaoTests.java From anomaly-detection with Apache License 2.0 | 6 votes |
@Test public void deleteModelCheckpoint_getDeleteRequest() { checkpointDao.deleteModelCheckpoint(modelId); ArgumentCaptor<DeleteRequest> deleteRequestCaptor = ArgumentCaptor.forClass(DeleteRequest.class); verify(clientUtil) .timedRequest( deleteRequestCaptor.capture(), anyObject(), Matchers.<BiConsumer<DeleteRequest, ActionListener<DeleteResponse>>>anyObject() ); DeleteRequest deleteRequest = deleteRequestCaptor.getValue(); assertEquals(indexName, deleteRequest.index()); assertEquals(CheckpointDao.DOC_TYPE, deleteRequest.type()); assertEquals(modelId, deleteRequest.id()); }
Example #2
Source File: ElasticSearchDAOV6.java From conductor with Apache License 2.0 | 6 votes |
@Override public void removeWorkflow(String workflowId) { try { long startTime = Instant.now().toEpochMilli(); DeleteRequest request = new DeleteRequest(workflowIndexName, WORKFLOW_DOC_TYPE, workflowId); DeleteResponse response = elasticSearchClient.delete(request).actionGet(); if (response.getResult() == DocWriteResponse.Result.DELETED) { LOGGER.error("Index removal failed - document not found by id: {}", workflowId); } long endTime = Instant.now().toEpochMilli(); LOGGER.debug("Time taken {} for removing workflow: {}", endTime - startTime, workflowId); Monitors.recordESIndexTime("remove_workflow", WORKFLOW_DOC_TYPE, endTime - startTime); Monitors.recordWorkerQueueSize("indexQueue", ((ThreadPoolExecutor) executorService).getQueue().size()); } catch (Throwable e) { LOGGER.error("Failed to remove workflow {} from index", workflowId, e); Monitors.error(CLASS_NAME, "remove"); } }
Example #3
Source File: TestDeleteElasticsearch5.java From nifi with Apache License 2.0 | 6 votes |
@Test public void testDeleteNotFound() throws IOException { restStatus = RestStatus.NOT_FOUND; deleteResponse = new DeleteResponse(null, TYPE1, documentId, 1, true) { @Override public RestStatus status() { return restStatus; } }; runner.enqueue(new byte [] {}, new HashMap<String, String>() {{ put("documentId", documentId); }}); runner.run(1, true, true); runner.assertAllFlowFilesTransferred(DeleteElasticsearch5.REL_NOT_FOUND, 1); final MockFlowFile out = runner.getFlowFilesForRelationship(DeleteElasticsearch5.REL_NOT_FOUND).get(0); assertNotNull(out); assertEquals(DeleteElasticsearch5.UNABLE_TO_DELETE_DOCUMENT_MESSAGE,out.getAttribute(DeleteElasticsearch5.ES_ERROR_MESSAGE)); out.assertAttributeEquals(DeleteElasticsearch5.ES_REST_STATUS, restStatus.toString()); out.assertAttributeEquals(DeleteElasticsearch5.ES_FILENAME, documentId); out.assertAttributeEquals(DeleteElasticsearch5.ES_INDEX, INDEX1); out.assertAttributeEquals(DeleteElasticsearch5.ES_TYPE, TYPE1); }
Example #4
Source File: DefaultElasticSearchService.java From vertx-elasticsearch-service with Apache License 2.0 | 6 votes |
@Override public void delete(String index, String type, String id, DeleteOptions options, Handler<AsyncResult<com.hubrick.vertx.elasticsearch.model.DeleteResponse>> resultHandler) { final DeleteRequestBuilder builder = client.prepareDelete(index, type, id); populateDeleteRequestBuilder(builder, options); builder.execute(new ActionListener<DeleteResponse>() { @Override public void onResponse(DeleteResponse deleteResponse) { resultHandler.handle(Future.succeededFuture(mapToDeleteResponse(deleteResponse))); } @Override public void onFailure(Exception t) { handleFailure(resultHandler, t); } }); }
Example #5
Source File: DetectorMappingRepositoryImplTest.java From adaptive-alerting with Apache License 2.0 | 6 votes |
@Test public void deleteMappingsByDetectorUUID_successful() throws Exception { val id = "adsvade8^szx"; val detectorUuid = UUID.randomUUID(); val searchIndex = "2"; val lookUpTime = 100; val deleteResponse = mockDeleteResponse(id); val searchResponse = mockSearchResponse(searchIndex, lookUpTime, detectorUuid.toString()); when(legacyElasticSearchClient.search(any(SearchRequest.class), eq(RequestOptions.DEFAULT))).thenReturn(searchResponse); when(legacyElasticSearchClient.delete(any(DeleteRequest.class), eq(RequestOptions.DEFAULT))).thenReturn(new DeleteResponse()); repoUnderTest.deleteMappingsByDetectorUUID(detectorUuid); verify(legacyElasticSearchClient, atLeastOnce()).delete(any(DeleteRequest.class), eq(RequestOptions.DEFAULT)); assertEquals(id, deleteResponse.getId()); assertEquals(elasticSearchProperties.getIndexName(), deleteResponse.getIndex()); assertEquals("DELETED", deleteResponse.getResult().toString()); }
Example #6
Source File: DetectorMappingRepositoryImplTest.java From adaptive-alerting with Apache License 2.0 | 6 votes |
private DeleteResponse mockDeleteResponse(String id) { DeleteResponse deleteResponse = mock(DeleteResponse.class); Result ResultOpt; when(deleteResponse.getId()).thenReturn(id); String indexName = elasticSearchProperties.getIndexName(); when(deleteResponse.getIndex()).thenReturn(indexName); try { byte[] byteopt = new byte[]{2}; // 2 - DELETED, DeleteResponse.Result ByteBuffer byteBuffer = ByteBuffer.wrap(byteopt); ByteBufferStreamInput byteoptbytebufferstream = new ByteBufferStreamInput(byteBuffer); ResultOpt = DocWriteResponse.Result.readFrom(byteoptbytebufferstream); when(deleteResponse.getResult()).thenReturn(ResultOpt); } catch (IOException e) { } return deleteResponse; }
Example #7
Source File: ElasticSearchRestDAOV5.java From conductor with Apache License 2.0 | 6 votes |
@Override public void removeWorkflow(String workflowId) { long startTime = Instant.now().toEpochMilli(); DeleteRequest request = new DeleteRequest(indexName, WORKFLOW_DOC_TYPE, workflowId); try { DeleteResponse response = elasticSearchClient.delete(request); if (response.getResult() == DocWriteResponse.Result.NOT_FOUND) { logger.error("Index removal failed - document not found by id: {}", workflowId); } long endTime = Instant.now().toEpochMilli(); logger.debug("Time taken {} for removing workflow: {}", endTime - startTime, workflowId); Monitors.recordESIndexTime("remove_workflow", WORKFLOW_DOC_TYPE, endTime - startTime); Monitors.recordWorkerQueueSize("indexQueue", ((ThreadPoolExecutor) executorService).getQueue().size()); } catch (Exception e) { logger.error("Failed to remove workflow {} from index", workflowId, e); Monitors.error(className, "remove"); } }
Example #8
Source File: ElasticSearchTypeImpl.java From core-ng-project with Apache License 2.0 | 6 votes |
@Override public boolean delete(DeleteRequest request) { var watch = new StopWatch(); String index = request.index == null ? this.index : request.index; boolean deleted = false; try { var deleteRequest = new org.elasticsearch.action.delete.DeleteRequest(index, request.id); DeleteResponse response = elasticSearch.client().delete(deleteRequest, RequestOptions.DEFAULT); deleted = response.getResult() == DocWriteResponse.Result.DELETED; return deleted; } catch (IOException e) { throw new UncheckedIOException(e); } finally { long elapsed = watch.elapsed(); ActionLogContext.track("elasticsearch", elapsed, 0, deleted ? 1 : 0); logger.debug("delete, index={}, id={}, elapsed={}", index, request.id, elapsed); checkSlowOperation(elapsed); } }
Example #9
Source File: TestDeleteElasticsearch5.java From nifi with Apache License 2.0 | 6 votes |
@Test public void testDeleteServerFailure() throws IOException { restStatus = RestStatus.SERVICE_UNAVAILABLE; deleteResponse = new DeleteResponse(null, TYPE1, documentId, 1, true) { @Override public RestStatus status() { return restStatus; } }; runner.enqueue(new byte [] {}, new HashMap<String, String>() {{ put("documentId", documentId); }}); runner.run(1, true, true); runner.assertAllFlowFilesTransferred(DeleteElasticsearch5.REL_FAILURE, 1); final MockFlowFile out = runner.getFlowFilesForRelationship(DeleteElasticsearch5.REL_FAILURE).get(0); assertNotNull(out); assertEquals(DeleteElasticsearch5.UNABLE_TO_DELETE_DOCUMENT_MESSAGE,out.getAttribute(DeleteElasticsearch5.ES_ERROR_MESSAGE)); out.assertAttributeEquals(DeleteElasticsearch5.ES_REST_STATUS, restStatus.toString()); out.assertAttributeEquals(DeleteElasticsearch5.ES_FILENAME, documentId); out.assertAttributeEquals(DeleteElasticsearch5.ES_INDEX, INDEX1); out.assertAttributeEquals(DeleteElasticsearch5.ES_TYPE, TYPE1); }
Example #10
Source File: SearchIndexServiceImpl.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@Override public void delete(final Repository repository, final String identifier) { checkNotNull(repository); checkNotNull(identifier); String indexName = repositoryIndexNames.get(repository.getName()); if (indexName == null) { return; } log.debug("Removing from index document {} from {}", identifier, repository); client.get().prepareDelete(indexName, TYPE, identifier).execute(new ActionListener<DeleteResponse>() { @Override public void onResponse(final DeleteResponse deleteResponse) { log.debug("successfully removed {} {} from index {}: {}", TYPE, identifier, indexName, deleteResponse); } @Override public void onFailure(final Throwable e) { log.error( "failed to remove {} {} from index {}; this is a sign that the Elasticsearch index thread pool is overloaded", TYPE, identifier, indexName, e); } }); }
Example #11
Source File: ESNestedSearchService.java From search-spring-boot-starter with Apache License 2.0 | 6 votes |
/** * 根据文档唯一Id删除指定的文档 * * @param esObject 删除参数 * @return <code>true</code>文档删除成功,<code>true</code>未找到对应文档. */ public SearchBaseResult<Boolean> delete(final DeleteESObject esObject) { final DeleteRequestBuilder deleteRequest = getDeleteRequest(esObject); try { SearchLogger.log(deleteRequest); if (esObject.isRefresh()) { deleteRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.WAIT_UNTIL); } DeleteResponse deleteResponse = deleteRequest.execute().actionGet(); SearchLogger.log(deleteRequest); if (DocWriteResponse.Result.DELETED == deleteResponse.getResult()) { return SearchBaseResult.success(Boolean.TRUE, Boolean.class); } if (DocWriteResponse.Result.NOT_FOUND == deleteResponse.getResult()) { return SearchBaseResult.success(Boolean.FALSE, Boolean.class); } return SearchBaseResult.faild(ESErrorCode.ELASTIC_ERROR_CODE, "ES返回结果不在预期范围内"); } catch (Exception ex) { SearchLogger.error("delete", ex); return SearchBaseResult.faild(ESErrorCode.ELASTIC_ERROR_CODE, "esMsg:" + ex.getMessage()); } }
Example #12
Source File: ElasticSearchManualTest.java From tutorials with MIT License | 6 votes |
@Test public void givenDocumentId_whenJavaObject_thenDeleteDocument() throws Exception { String jsonObject = "{\"age\":10,\"dateOfBirth\":1471455886564,\"fullName\":\"Johan Doe\"}"; IndexRequest indexRequest = new IndexRequest("people"); indexRequest.source(jsonObject, XContentType.JSON); IndexResponse response = client.index(indexRequest, RequestOptions.DEFAULT); String id = response.getId(); GetRequest getRequest = new GetRequest("people"); getRequest.id(id); GetResponse getResponse = client.get(getRequest, RequestOptions.DEFAULT); System.out.println(getResponse.getSourceAsString()); DeleteRequest deleteRequest = new DeleteRequest("people"); deleteRequest.id(id); DeleteResponse deleteResponse = client.delete(deleteRequest, RequestOptions.DEFAULT); assertEquals(Result.DELETED, deleteResponse.getResult()); }
Example #13
Source File: TestDeleteElasticsearch5.java From nifi with Apache License 2.0 | 6 votes |
@Test public void testDeleteSuccessful() throws IOException { restStatus = RestStatus.OK; deleteResponse = new DeleteResponse(null, TYPE1, documentId, 1, true) { @Override public RestStatus status() { return restStatus; } }; runner.enqueue(new byte [] {}, new HashMap<String, String>() {{ put("documentId", documentId); }}); runner.run(1, true, true); runner.assertAllFlowFilesTransferred(DeleteElasticsearch5.REL_SUCCESS, 1); final MockFlowFile out = runner.getFlowFilesForRelationship(DeleteElasticsearch5.REL_SUCCESS).get(0); assertNotNull(out); assertEquals(null,out.getAttribute(DeleteElasticsearch5.ES_ERROR_MESSAGE)); out.assertAttributeEquals(DeleteElasticsearch5.ES_FILENAME, documentId); out.assertAttributeEquals(DeleteElasticsearch5.ES_INDEX, INDEX1); out.assertAttributeEquals(DeleteElasticsearch5.ES_TYPE, TYPE1); }
Example #14
Source File: EsAbstractBehavior.java From fess with Apache License 2.0 | 5 votes |
@Override protected int delegateDelete(final Entity entity, final DeleteOption<? extends ConditionBean> option) { final EsAbstractEntity esEntity = (EsAbstractEntity) entity; final DeleteRequestBuilder builder = createDeleteRequest(esEntity); final DeleteResponse response = builder.execute().actionGet(deleteTimeout); return response.getResult() == Result.DELETED ? 1 : 0; }
Example #15
Source File: ElasticSearchController.java From springboot-learn with MIT License | 5 votes |
@DeleteMapping("/delete/book/novel") public ResponseEntity delete(@RequestParam(name = "id", defaultValue = "") String id) { // 查询结果 DeleteResponse result = transportClient.prepareDelete(INDEX, TYPE, id) .get(); return new ResponseEntity(result.getResult(), HttpStatus.OK); }
Example #16
Source File: ElasticsearchIntegrationTest.java From wildfly-camel with Apache License 2.0 | 5 votes |
@Test public void deleteRequestBody() throws Exception { CamelContext camelctx = createCamelContext(); camelctx.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("direct:index") .to("elasticsearch-rest://elasticsearch?operation=Index&indexName=twitter&hostAddresses=" + getElasticsearchHost()); from("direct:delete") .to("elasticsearch-rest://elasticsearch?operation=Delete&indexName=twitter&hostAddresses=" + getElasticsearchHost()); } }); camelctx.start(); try { ProducerTemplate template = camelctx.createProducerTemplate(); DeleteRequest request = new DeleteRequest(PREFIX + "foo"); IndexRequest idxreq = new IndexRequest(PREFIX + "foo") .id(PREFIX + "testId").source(PREFIX + "content", PREFIX + "hello"); String documentId = template.requestBody("direct:index", idxreq, String.class); DeleteResponse.Result response = template.requestBody("direct:delete", request.id(documentId), DeleteResponse.Result.class); Assert.assertNotNull(response); } finally { camelctx.close(); } }
Example #17
Source File: AdapterActionFutureActionGetMethodsInterceptor.java From skywalking with Apache License 2.0 | 5 votes |
private void parseDeleteResponse(DeleteResponse deleteResponse, AbstractSpan span) { if (TRACE_DSL) { String tagValue = deleteResponse.toString(); tagValue = ELASTICSEARCH_DSL_LENGTH_THRESHOLD > 0 ? StringUtil.cut(tagValue, ELASTICSEARCH_DSL_LENGTH_THRESHOLD) : tagValue; Tags.DB_STATEMENT.set(span, tagValue); } }
Example #18
Source File: BaseElasticSearchIndexBuilder.java From sakai with Educational Community License v2.0 | 5 votes |
protected void executeBulkRequest(BulkRequestBuilder bulkRequest) { BulkResponse bulkResponse = bulkRequest.execute().actionGet(); getLog().info("Bulk request of batch size: " + bulkRequest.numberOfActions() + " took " + bulkResponse.getTookInMillis() + " ms in index builder: " + getName()); for (BulkItemResponse response : bulkResponse.getItems()) { if (response.getResponse() instanceof DeleteResponse) { DeleteResponse deleteResponse = response.getResponse(); if (response.isFailed()) { getLog().error("Problem deleting doc: " + response.getId() + " in index builder: " + getName() + " error: " + response.getFailureMessage()); } else if (!deleteResponse.isFound()) { getLog().debug("ES could not find a doc with id: " + deleteResponse.getId() + " to delete in index builder: " + getName()); } else { getLog().debug("ES deleted a doc with id: " + deleteResponse.getId() + " in index builder: " + getName()); } } else if (response.getResponse() instanceof IndexResponse) { IndexResponse indexResponse = response.getResponse(); if (response.isFailed()) { getLog().error("Problem updating content for doc: " + response.getId() + " in index builder: " + getName() + " error: " + response.getFailureMessage()); } else { getLog().debug("ES indexed content for doc with id: " + indexResponse.getId() + " in index builder: " + getName()); } } } }
Example #19
Source File: ElasticsearchIndexManager.java From syncope with Apache License 2.0 | 5 votes |
@TransactionalEventListener public void after(final AnyDeletedEvent event) throws IOException { LOG.debug("About to delete index for {}[{}]", event.getAnyTypeKind(), event.getAnyKey()); DeleteRequest request = new DeleteRequest( ElasticsearchUtils.getContextDomainName(AuthContextUtils.getDomain(), event.getAnyTypeKind()), event.getAnyKey()); DeleteResponse response = client.delete(request, RequestOptions.DEFAULT); LOG.debug("Index successfully deleted for {}[{}]: {}", event.getAnyTypeKind(), event.getAnyKey(), response); }
Example #20
Source File: TestDeleteElasticsearch5.java From nifi with Apache License 2.0 | 5 votes |
@Before public void setUp() throws IOException { currentTimeMillis = System.currentTimeMillis(); documentId = String.valueOf(currentTimeMillis); mockDeleteProcessor = new DeleteElasticsearch5() { @Override protected DeleteRequestBuilder prepareDeleteRequest(String index, String docId, String docType) { return null; } @Override protected DeleteResponse doDelete(DeleteRequestBuilder requestBuilder) throws InterruptedException, ExecutionException { return deleteResponse; } @Override public void setup(ProcessContext context) { } }; runner = TestRunners.newTestRunner(mockDeleteProcessor); runner.setProperty(AbstractElasticsearch5TransportClientProcessor.CLUSTER_NAME, "elasticsearch"); runner.setProperty(AbstractElasticsearch5TransportClientProcessor.HOSTS, "127.0.0.1:9300"); runner.setProperty(AbstractElasticsearch5TransportClientProcessor.PING_TIMEOUT, "5s"); runner.setProperty(AbstractElasticsearch5TransportClientProcessor.SAMPLER_INTERVAL, "5s"); runner.setProperty(DeleteElasticsearch5.INDEX, INDEX1); runner.assertNotValid(); runner.setProperty(DeleteElasticsearch5.TYPE, TYPE1); runner.assertNotValid(); runner.setProperty(DeleteElasticsearch5.DOCUMENT_ID, "${documentId}"); runner.assertValid(); }
Example #21
Source File: ElasticSearchServer.java From vind with Apache License 2.0 | 5 votes |
@Override public DeleteResult deleteWithin(Document doc, int withinMs) { log.warn("Parameter 'within' not in use in elastic search backend"); try { final StopWatch elapsedTime = StopWatch.createStarted(); elasticClientLogger.debug(">>> delete({})", doc.getId()); final DeleteResponse deleteResponse = elasticSearchClient.deleteById(doc.getId()); elapsedTime.stop(); return new DeleteResult(elapsedTime.getTime()).setElapsedTime(elapsedTime.getTime()); } catch (ElasticsearchException | IOException e) { log.error("Cannot delete document {}", doc.getId() , e); throw new SearchServerException("Cannot delete document", e); } }
Example #22
Source File: TransportClient.java From elasticsearch-jest-example with MIT License | 5 votes |
/** * 仅仅只删除索引 * @param index * @param type * @param id */ private static void deleteIndex(String index, String type, String id){ Client client = createTransportClient(); DeleteResponse response = client.prepareDelete(index, type, id) .execute() .actionGet(); boolean isFound = response.isFound(); System.out.println("索引是否 存在:"+isFound); // 发现doc已删除则返回true System.out.println("****************index ***********************"); // Index name String _index = response.getIndex(); // Type name String _type = response.getType(); // Document ID (generated or not) String _id = response.getId(); // Version (if it's the first time you index this document, you will get: 1) long _version = response.getVersion(); System.out.println(_index+","+_type+","+_id+","+_version); //优化索引 OptimizeRequest optimizeRequest = new OptimizeRequest(index); OptimizeResponse optimizeResponse = client.admin().indices().optimize(optimizeRequest).actionGet(); System.out.println(optimizeResponse.getTotalShards()+","+optimizeResponse.getSuccessfulShards()+","+optimizeResponse.getFailedShards()); //刷新索引 FlushRequest flushRequest = new FlushRequest(index); flushRequest.force(true); FlushResponse flushResponse = client.admin().indices().flush(flushRequest).actionGet(); System.out.println(flushResponse.getTotalShards()+","+flushResponse.getSuccessfulShards()+","+flushResponse.getFailedShards()); }
Example #23
Source File: BulkItemResponse.java From Elasticsearch with Apache License 2.0 | 5 votes |
/** * The type of the action. */ public String getType() { if (failure != null) { return failure.getType(); } if (response instanceof IndexResponse) { return ((IndexResponse) response).getType(); } else if (response instanceof DeleteResponse) { return ((DeleteResponse) response).getType(); } else if (response instanceof UpdateResponse) { return ((UpdateResponse) response).getType(); } return null; }
Example #24
Source File: BulkItemResponse.java From Elasticsearch with Apache License 2.0 | 5 votes |
/** * The version of the action. */ public long getVersion() { if (failure != null) { return -1; } if (response instanceof IndexResponse) { return ((IndexResponse) response).getVersion(); } else if (response instanceof DeleteResponse) { return ((DeleteResponse) response).getVersion(); } else if (response instanceof UpdateResponse) { return ((UpdateResponse) response).getVersion(); } return -1; }
Example #25
Source File: OpenShiftRestResponseTest.java From openshift-elasticsearch-plugin with Apache License 2.0 | 5 votes |
@Test public void testDeleteResponse() throws Exception { String body = "{\"found\":true,\"_index\":\"%s\"" + ",\"_type\":\"config\",\"_id\":\"0\",\"_version\":2,\"result\":\"deleted\",\"_shards\":" + "{\"total\":2,\"successful\":1,\"failed\":0}}"; XContentParser parser = givenContentParser(body); DeleteResponse actionResponse = DeleteResponse.fromXContent(parser); OpenShiftRestResponse osResponse = whenCreatingResponseResponse(actionResponse); thenResponseShouldBeModified(osResponse, body); }
Example #26
Source File: BaseElasticSearchIndexBuilder.java From sakai with Educational Community License v2.0 | 5 votes |
protected void executeBulkRequest(BulkRequestBuilder bulkRequest) { BulkResponse bulkResponse = bulkRequest.execute().actionGet(); getLog().info("Bulk request of batch size: " + bulkRequest.numberOfActions() + " took " + bulkResponse.getTookInMillis() + " ms in index builder: " + getName()); for (BulkItemResponse response : bulkResponse.getItems()) { if (response.getResponse() instanceof DeleteResponse) { DeleteResponse deleteResponse = response.getResponse(); if (response.isFailed()) { getLog().error("Problem deleting doc: " + response.getId() + " in index builder: " + getName() + " error: " + response.getFailureMessage()); } else if (!deleteResponse.isFound()) { getLog().debug("ES could not find a doc with id: " + deleteResponse.getId() + " to delete in index builder: " + getName()); } else { getLog().debug("ES deleted a doc with id: " + deleteResponse.getId() + " in index builder: " + getName()); } } else if (response.getResponse() instanceof IndexResponse) { IndexResponse indexResponse = response.getResponse(); if (response.isFailed()) { getLog().error("Problem updating content for doc: " + response.getId() + " in index builder: " + getName() + " error: " + response.getFailureMessage()); } else { getLog().debug("ES indexed content for doc with id: " + indexResponse.getId() + " in index builder: " + getName()); } } } }
Example #27
Source File: EsAbstractBehavior.java From fess with Apache License 2.0 | 5 votes |
@Override protected int delegateDelete(final Entity entity, final DeleteOption<? extends ConditionBean> option) { final EsAbstractEntity esEntity = (EsAbstractEntity) entity; final DeleteRequestBuilder builder = createDeleteRequest(esEntity); final DeleteResponse response = builder.execute().actionGet(deleteTimeout); return response.getResult() == Result.DELETED ? 1 : 0; }
Example #28
Source File: RunDao.java From usergrid with Apache License 2.0 | 5 votes |
/** * * @param run * @return */ public boolean delete( Run run ) { DeleteResponse response = elasticSearchClient.getClient() .prepareDelete( DAO_INDEX_KEY, DAO_TYPE_KEY, run.getId() ) .setRefresh( true ) .execute() .actionGet(); return response.isFound(); }
Example #29
Source File: DeleteServiceDef.java From sfs with Apache License 2.0 | 5 votes |
@Override public Observable<Optional<PersistentServiceDef>> call(final PersistentServiceDef persistentServiceDef) { final Elasticsearch elasticSearch = vertxContext.verticle().elasticsearch(); final String id = persistentServiceDef.getId(); if (LOGGER.isDebugEnabled()) { LOGGER.debug(format("Request {%s,%s,%s}", elasticSearch.defaultType(), elasticSearch.serviceDefTypeIndex(), id)); } DeleteRequestBuilder request = elasticSearch.get() .prepareDelete( elasticSearch.serviceDefTypeIndex(), elasticSearch.defaultType(), id) .setTimeout(timeValueMillis(elasticSearch.getDefaultDeleteTimeout() - 10)) .setVersion(persistentServiceDef.getVersion()); return elasticSearch.execute(vertxContext, request, elasticSearch.getDefaultDeleteTimeout()) .map(new Func1<Optional<DeleteResponse>, Optional<PersistentServiceDef>>() { @Override public Optional<PersistentServiceDef> call(Optional<DeleteResponse> oDeleteResponse) { if (oDeleteResponse.isPresent()) { if (LOGGER.isDebugEnabled()) { LOGGER.debug(format("Response {%s,%s,%s} = %s", elasticSearch.defaultType(), elasticSearch.serviceDefTypeIndex(), id, Jsonify.toString(oDeleteResponse.get()))); } return fromNullable(persistentServiceDef); } else { LOGGER.debug(format("Response {%s,%s,%s} = %s", elasticSearch.defaultType(), elasticSearch.serviceDefTypeIndex(), id, "null")); return absent(); } } }); }
Example #30
Source File: ModelsAction.java From zentity with Apache License 2.0 | 5 votes |
/** * Delete one entity model by its type. * * @param entityType The entity type. * @param client The client that will communicate with Elasticsearch. * @return The response from Elasticsearch. * @throws ForbiddenException */ private static DeleteResponse deleteEntityModel(String entityType, NodeClient client) throws ForbiddenException { DeleteRequestBuilder request = client.prepareDelete(INDEX_NAME, "doc", entityType); request.setRefreshPolicy("wait_for"); try { return request.get(); } catch (IndexNotFoundException e) { try { SetupAction.createIndex(client); } catch (ElasticsearchSecurityException se) { throw new ForbiddenException("The .zentity-models index does not exist and you do not have the 'create_index' privilege. An authorized user must create the index by submitting: POST _zentity/_setup"); } return request.get(); } }