当前位置: 首页>>代码示例>>Java>>正文


Java DeleteResponse类代码示例

本文整理汇总了Java中org.elasticsearch.action.delete.DeleteResponse的典型用法代码示例。如果您正苦于以下问题:Java DeleteResponse类的具体用法?Java DeleteResponse怎么用?Java DeleteResponse使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DeleteResponse类属于org.elasticsearch.action.delete包,在下文中一共展示了DeleteResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deleteDocument

import org.elasticsearch.action.delete.DeleteResponse; //导入依赖的package包/类
/**
 * This method delete the matched Document
 */
@Override
public void deleteDocument() {
    try {
        client = ESclient.getInstant();
        DeleteResponse deleteResponse = client.prepareDelete("school", "tenth", "1")
                //                    .setOperationThreaded(false)
                .get();
        if (deleteResponse != null) {
            deleteResponse.status();
            deleteResponse.toString();
            log.info("Document has been deleted...");
        }
    } catch (Exception ex) {
        log.error("Exception occurred while delete Document : " + ex, ex);
    }
}
 
开发者ID:sundarcse1216,项目名称:es-crud,代码行数:20,代码来源:ElasticSearchCrudImpl.java

示例2: testExternalVersioningInitialDelete

import org.elasticsearch.action.delete.DeleteResponse; //导入依赖的package包/类
public void testExternalVersioningInitialDelete() throws Exception {
    createIndex("test");
    ensureGreen();

    // Note - external version doesn't throw version conflicts on deletes of non existent records. This is different from internal versioning

    DeleteResponse deleteResponse = client().prepareDelete("test", "type", "1").setVersion(17).setVersionType(VersionType.EXTERNAL).execute().actionGet();
    assertEquals(DocWriteResponse.Result.NOT_FOUND, deleteResponse.getResult());

    // this should conflict with the delete command transaction which told us that the object was deleted at version 17.
    assertThrows(
            client().prepareIndex("test", "type", "1").setSource("field1", "value1_1").setVersion(13).setVersionType(VersionType.EXTERNAL).execute(),
            VersionConflictEngineException.class
    );

    IndexResponse indexResponse = client().prepareIndex("test", "type", "1").setSource("field1", "value1_1").setVersion(18).
            setVersionType(VersionType.EXTERNAL).execute().actionGet();
    assertThat(indexResponse.getVersion(), equalTo(18L));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:SimpleVersioningIT.java

示例3: unindex

import org.elasticsearch.action.delete.DeleteResponse; //导入依赖的package包/类
@Override
public void unindex(String appid, ParaObject po) {
	if (po == null || StringUtils.isBlank(po.getId()) || StringUtils.isBlank(appid)) {
		return;
	}
	try {
		DeleteRequestBuilder drb = client().prepareDelete(getIndexName(appid), getType(), po.getId());
		ActionListener<DeleteResponse> responseHandler = ElasticSearchUtils.getIndexResponseHandler();
		if (isAsyncEnabled()) {
			drb.execute(responseHandler);
		} else {
			responseHandler.onResponse(drb.execute().actionGet());
		}
		logger.debug("Search.unindex() {}", po.getId());
	} catch (Exception e) {
		logger.warn(null, e);
	}
}
 
开发者ID:Erudika,项目名称:para-search-elasticsearch,代码行数:19,代码来源:ElasticSearch.java

示例4: writeTo

import org.elasticsearch.action.delete.DeleteResponse; //导入依赖的package包/类
@Override
public void writeTo(StreamOutput out) throws IOException {
    out.writeVInt(id);
    out.writeString(opType);

    if (response == null) {
        out.writeByte((byte) 2);
    } else {
        if (response instanceof IndexResponse) {
            out.writeByte((byte) 0);
        } else if (response instanceof DeleteResponse) {
            out.writeByte((byte) 1);
        } else if (response instanceof UpdateResponse) {
            out.writeByte((byte) 3); // make 3 instead of 2, because 2 is already in use for 'no responses'
        }
        response.writeTo(out);
    }
    if (failure == null) {
        out.writeBoolean(false);
    } else {
        out.writeBoolean(true);
        failure.writeTo(out);
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:25,代码来源:BulkItemResponse.java

示例5: testDeleteNotFound

import org.elasticsearch.action.delete.DeleteResponse; //导入依赖的package包/类
@Test
public void testDeleteNotFound() throws Exception {
    String id = "1";
    DeleteRequestBuilder mockDeleteRequestBuilder = mock(DeleteRequestBuilder.class);
    ListenableActionFuture mockListenableActionFuture = mock(ListenableActionFuture.class);
    DeleteResponse mockDeleteResponse = mock(DeleteResponse.class);

    when(client.prepareDelete("steckbrief", "steckbrief", id)).thenReturn(mockDeleteRequestBuilder);
    when(mockDeleteRequestBuilder.execute()).thenReturn(mockListenableActionFuture);
    when(mockListenableActionFuture.actionGet()).thenReturn(mockDeleteResponse);
    when(mockDeleteResponse.isFound()).thenReturn(false);

    ResponseEntity response = documentController.delete(id);

    assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
}
 
开发者ID:pivio,项目名称:pivio-server,代码行数:17,代码来源:DocumentControllerTest.java

示例6: processDelete

import org.elasticsearch.action.delete.DeleteResponse; //导入依赖的package包/类
/**
 * Processes a "delete" request.
 * 
 * @param urlItems Items of the URL
 * @return Result of the delete request, it contains the id of the deleted document
 */
private InterpreterResult processDelete(String[] urlItems) {

  if (urlItems.length != 3 
      || StringUtils.isEmpty(urlItems[0]) 
      || StringUtils.isEmpty(urlItems[1]) 
      || StringUtils.isEmpty(urlItems[2])) {
    return new InterpreterResult(InterpreterResult.Code.ERROR,
                                 "Bad URL (it should be /index/type/id)");
  }

  final DeleteResponse response = client
    .prepareDelete(urlItems[0], urlItems[1], urlItems[2])
    .get();
      
  if (response.isFound()) {
    return new InterpreterResult(
      InterpreterResult.Code.SUCCESS,
      InterpreterResult.Type.TEXT,
      response.getId());
  }
      
  return new InterpreterResult(InterpreterResult.Code.ERROR, "Document not found");
}
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:30,代码来源:ElasticsearchInterpreter.java

示例7: deleteDocById

import org.elasticsearch.action.delete.DeleteResponse; //导入依赖的package包/类
/**
 * 删除文档
 * 
 * @param id
 */
public boolean deleteDocById(String docId) {
    try {
        // 删除
        DeleteResponse resp = ESClient.getClient()
                .prepareDelete(this.currentIndexName, this.indexType.getTypeName(), docId)
                .setOperationThreaded(false).execute().actionGet();
        // 刷新
        ESClient.getClient().admin().indices()
                .refresh(new RefreshRequest(this.currentIndexName)).actionGet();
        if (resp.isFound()) {
            log.warn("delete index sunccess,indexname:{},type:{},delete {} items",
                    this.indexType.getIndexName(), this.indexType.getTypeName(), 1);
            return resp.isFound();
        }
    } catch (Exception e) {
        log.error("delete Doc fail,indexname:{},type:{}", this.indexType.getIndexName(),
                this.indexType.getTypeName());
    }
    return false;
}
 
开发者ID:hailin0,项目名称:es-service-parent,代码行数:26,代码来源:IndexTransaction.java

示例8: testDelete

import org.elasticsearch.action.delete.DeleteResponse; //导入依赖的package包/类
@Test
public void testDelete() throws Exception {
    //first, INDEX a value
    Map<String, String> map = createIndexedData();
    sendBody("direct:index", map);
    String indexId = template.requestBody("direct:index", map, String.class);
    assertNotNull("indexId should be set", indexId);

    //now, verify GET succeeded
    GetResponse response = template.requestBody("direct:get", indexId, GetResponse.class);
    assertNotNull("response should not be null", response);
    assertNotNull("response source should not be null", response.getSource());

    //now, perform DELETE
    DeleteResponse deleteResponse = template.requestBody("direct:delete", indexId, DeleteResponse.class);
    assertNotNull("response should not be null", deleteResponse);

    //now, verify GET fails to find the indexed value
    response = template.requestBody("direct:get", indexId, GetResponse.class);
    assertNotNull("response should not be null", response);
    assertNull("response source should be null", response.getSource());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:23,代码来源:ElasticsearchGetSearchDeleteExistsUpdateTest.java

示例9: deleteRequestBody

import org.elasticsearch.action.delete.DeleteResponse; //导入依赖的package包/类
@Test
public void deleteRequestBody() throws Exception {
    String prefix = createPrefix();

    // given
    DeleteRequest request = new DeleteRequest(prefix + "foo").type(prefix + "bar");

    // when
    String documentId = template.requestBody("direct:index",
            new IndexRequest("" + prefix + "foo", "" + prefix + "bar", "" + prefix + "testId")
                    .source("{\"" + prefix + "content\": \"" + prefix + "hello\"}"), String.class);
    DeleteResponse response = template.requestBody("direct:delete",
            request.id(documentId), DeleteResponse.class);

    // then
    assertThat(response, notNullValue());
    assertThat(documentId, equalTo(response.getId()));
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:ElasticsearchGetSearchDeleteExistsUpdateTest.java

示例10: getIndex

import org.elasticsearch.action.delete.DeleteResponse; //导入依赖的package包/类
private String getIndex(ActionResponse response) {
    String index = "";

    if (response instanceof IndexResponse) {
        index = ((IndexResponse) response).getIndex();
    } else if (response instanceof GetResponse) {
        index = ((GetResponse) response).getIndex();
    } else if (response instanceof DeleteResponse) {
        index = ((DeleteResponse) response).getIndex();
    }

    if (isKibanaUserIndex(index)) {
        index = kibanaIndex;
    }

    return index;
}
 
开发者ID:fabric8io,项目名称:openshift-elasticsearch-plugin,代码行数:18,代码来源:KibanaUserReindexAction.java

示例11: delete

import org.elasticsearch.action.delete.DeleteResponse; //导入依赖的package包/类
@Override
public void delete(final Repository repository, final String identifier) {
  checkNotNull(repository);
  checkNotNull(identifier);
  String indexName = repositoryNameMapping.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);
    }
  });
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:23,代码来源:SearchServiceImpl.java

示例12: delete

import org.elasticsearch.action.delete.DeleteResponse; //导入依赖的package包/类
@Override
public boolean delete(DeleteRequest request) {
    StopWatch watch = new StopWatch();
    String index = request.index == null ? this.index : request.index;
    boolean deleted = false;
    try {
        DeleteResponse response = client().prepareDelete(index, type, request.id).get();
        deleted = response.getResult() == DocWriteResponse.Result.DELETED;
        return deleted;
    } catch (ElasticsearchException e) {
        throw new SearchException(e);   // due to elastic search uses async executor to run, we have to wrap the exception to retain the original place caused the exception
    } finally {
        long elapsedTime = watch.elapsedTime();
        ActionLogContext.track("elasticsearch", elapsedTime, 0, deleted ? 1 : 0);
        logger.debug("delete, index={}, type={}, id={}, elapsedTime={}", index, type, request.id, elapsedTime);
        checkSlowOperation(elapsedTime);
    }
}
 
开发者ID:neowu,项目名称:core-ng-project,代码行数:19,代码来源:ElasticSearchTypeImpl.java

示例13: delete

import org.elasticsearch.action.delete.DeleteResponse; //导入依赖的package包/类
protected GDSResult<Boolean> delete(Class<?> clazz, String id) {
	if (id == null)
		throw new NullPointerException("delete id cannot be null");
	
	final GDSAsyncImpl<Boolean> callback = new GDSAsyncImpl<>();

	String kind = GDSClass.getKind(clazz);
	gds.getClient().prepareDelete(gds.indexFor(kind), kind, id).execute(new ActionListener<DeleteResponse>() {
		
		@Override
		public void onResponse(DeleteResponse response) {
			callback.onSuccess(response.isFound(), null);
		}
		
		@Override
		public void onFailure(Throwable e) {
			callback.onSuccess(false, e);
		}
	});
	
	return callback;
}
 
开发者ID:Ryan-ZA,项目名称:async-elastic-orm,代码行数:23,代码来源:GDSDeleterImpl.java

示例14: deleteDocument

import org.elasticsearch.action.delete.DeleteResponse; //导入依赖的package包/类
@Override
public void deleteDocument(SearchContext searchContext, String uid)
        throws SearchException {

    try {
        Client client = getClient();

        DeleteRequestBuilder deleteRequestBuilder = client.prepareDelete(
                Utilities.getIndexName(searchContext),
                "documents", uid);

        Future<DeleteResponse> future = deleteRequestBuilder.execute();

        DeleteResponse deleteResponse = future.get();

    } catch (Exception e) {
        throw new SearchException("Unable to delete document " + uid, e);
    }
}
 
开发者ID:R-Knowsys,项目名称:elasticray,代码行数:20,代码来源:ElasticsearchIndexWriter.java

示例15: deleteUser

import org.elasticsearch.action.delete.DeleteResponse; //导入依赖的package包/类
@Override
public void deleteUser(final String username,
        final ActionListener<Void> listener) {
    client.prepareDelete(authIndex, userType, getUserId(username))
            .setRefresh(true).execute(new ActionListener<DeleteResponse>() {

                @Override
                public void onResponse(final DeleteResponse response) {
                    if (response.isFound()) {
                        listener.onResponse(null);
                    } else {
                        listener.onFailure(new AuthException(
                            RestStatus.BAD_REQUEST, "Could not delete "
                            + username));
                    }
                }

                @Override
                public void onFailure(final Throwable e) {
                    listener.onFailure(new AuthException(
                            RestStatus.INTERNAL_SERVER_ERROR,
                            "Could not delete " + username, e));
                }
            });

}
 
开发者ID:codelibs,项目名称:elasticsearch-auth,代码行数:27,代码来源:IndexAuthenticator.java


注:本文中的org.elasticsearch.action.delete.DeleteResponse类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。