org.elasticsearch.action.deletebyquery.DeleteByQueryResponse Java Examples

The following examples show how to use org.elasticsearch.action.deletebyquery.DeleteByQueryResponse. 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: DeleteByQueryRequestBuilder.java    From elasticshell with Apache License 2.0 6 votes vote down vote up
@Override
protected XContentBuilder toXContent(DeleteByQueryRequest request, DeleteByQueryResponse response, XContentBuilder builder) throws IOException {
    builder.startObject().field(Fields.OK, true);
    builder.startObject("_indices");
    for (IndexDeleteByQueryResponse indexDeleteByQueryResponse : response.getIndices().values()) {
        builder.startObject(indexDeleteByQueryResponse.getIndex(), XContentBuilder.FieldCaseConversion.NONE);
        builder.startObject("_shards");
        builder.field("total", indexDeleteByQueryResponse.getTotalShards());
        builder.field("successful", indexDeleteByQueryResponse.getSuccessfulShards());
        builder.field("failed", indexDeleteByQueryResponse.getFailedShards());
        builder.endObject();
        builder.endObject();
    }
    builder.endObject();
    builder.endObject();
    return builder;
}
 
Example #2
Source File: Search.java    From elasticsearch-rest-command with The Unlicense 6 votes vote down vote up
public void buildDelete(XContentBuilder builder,
		DeleteByQueryResponse response) throws IOException {

	builder.startObject();
	builder.startObject("_indices");
	for (IndexDeleteByQueryResponse indexDeleteByQueryResponse : response
			.getIndices().values()) {
		builder.startObject(indexDeleteByQueryResponse.getIndex(),
				XContentBuilder.FieldCaseConversion.NONE);

		builder.startObject("_shards");
		builder.field("total", indexDeleteByQueryResponse.getTotalShards());
		builder.field("successful",
				indexDeleteByQueryResponse.getSuccessfulShards());
		builder.field("failed",
				indexDeleteByQueryResponse.getFailedShards());
		builder.endObject();

		builder.endObject();
	}
	builder.endObject();
	builder.endObject();
}
 
Example #3
Source File: QuestionElasticSearchIndexBuilder.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
protected void deleteAllDocumentForQuestionPool(String qpId) {
    getLog().debug("removing all documents from question index for questionPool: " + qpId);
    DeleteByQueryResponse response = client.prepareDeleteByQuery(indexName)
            .setQuery(termQuery("questionPoolId", qpId))
            .setTypes(indexedDocumentType)
            .execute()
            .actionGet();
}
 
Example #4
Source File: EsEntityIndexImpl.java    From usergrid with Apache License 2.0 5 votes vote down vote up
/**
 * Validate the response doesn't contain errors, if it does, fail fast at the first error we encounter
 */
private void checkDeleteByQueryResponse( final QueryBuilder query, final DeleteByQueryResponse response ) {

    for ( IndexDeleteByQueryResponse indexDeleteByQueryResponse : response ) {
        final ShardOperationFailedException[] failures = indexDeleteByQueryResponse.getFailures();

        for ( ShardOperationFailedException failedException : failures ) {
            logger.error("Unable to delete by query {}. Failed with code {} and reason {} on shard {} in index {}",
                query.toString(),
                failedException.status().getStatus(), failedException.reason(),
                failedException.shardId(), failedException.index() );
        }
    }
}
 
Example #5
Source File: SiteElasticSearchIndexBuilder.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
protected void deleteAllDocumentForSite(String siteId) {
    getLog().debug("removing all documents from search index for siteId: " + siteId);
    DeleteByQueryResponse response = client.prepareDeleteByQuery(indexName)
            .setQuery(termQuery(SearchService.FIELD_SITEID, siteId))
            .setTypes(indexedDocumentType)
            .execute()
            .actionGet();
}
 
Example #6
Source File: QuestionElasticSearchIndexBuilder.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
protected void deleteAllDocumentForQuestionPool(String qpId) {
    getLog().debug("removing all documents from question index for questionPool: " + qpId);
    DeleteByQueryResponse response = client.prepareDeleteByQuery(indexName)
            .setQuery(termQuery("questionPoolId", qpId))
            .setTypes(indexedDocumentType)
            .execute()
            .actionGet();
}
 
Example #7
Source File: QuestionElasticSearchIndexBuilder.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
private void deleteAllDocumentForSite(String siteId) {
    getLog().debug("removing all documents from question index for siteId: " + siteId);
    DeleteByQueryResponse response = client.prepareDeleteByQuery(indexName)
            .setQuery(termQuery("site", siteId))
            .setTypes(indexedDocumentType)
            .execute()
            .actionGet();
}
 
Example #8
Source File: ESJavaRDDFT.java    From deep-spark with Apache License 2.0 5 votes vote down vote up
private static void deleteDataSet() {

        try {
            DeleteByQueryResponse delete = client.prepareDeleteByQuery(ES_INDEX)
                    .setQuery(termQuery("_type", ES_TYPE))
                    .execute()
                    .actionGet();
            delete.status();

        } catch (Exception e) {

            //            e.printStackTrace();
        }
    }
 
Example #9
Source File: InternalEsClient.java    From io with Apache License 2.0 5 votes vote down vote up
/**
 * 指定されたクエリを使用してデータの削除を行う.
 * @param index 削除対象のインデックス
 * @param deleteQuery 削除対象を指定するクエリ
 * @return ES応答
 */
public DeleteByQueryResponse deleteByQuery(String index, QueryBuilder deleteQuery) {
    DeleteByQueryResponse response = new DeleteByQueryRequestBuilder(esTransportClient, DeleteByQueryAction.INSTANCE)
    		.setIndices(index)
            .setQuery(deleteQuery).execute().actionGet();
    return response;
}
 
Example #10
Source File: SiteElasticSearchIndexBuilder.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
protected void deleteAllDocumentForSite(String siteId) {
    getLog().debug("removing all documents from search index for siteId: " + siteId);
    DeleteByQueryResponse response = client.prepareDeleteByQuery(indexName)
            .setQuery(termQuery(SearchService.FIELD_SITEID, siteId))
            .setTypes(indexedDocumentType)
            .execute()
            .actionGet();
}
 
Example #11
Source File: QuestionElasticSearchIndexBuilder.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
private void deleteAllDocumentForSite(String siteId) {
    getLog().debug("removing all documents from question index for siteId: " + siteId);
    DeleteByQueryResponse response = client.prepareDeleteByQuery(indexName)
            .setQuery(termQuery("site", siteId))
            .setTypes(indexedDocumentType)
            .execute()
            .actionGet();
}
 
Example #12
Source File: EsRetryTest.java    From io with Apache License 2.0 4 votes vote down vote up
@Override
public DeleteByQueryResponse deleteByQuery(String index, QueryBuilder deleteQuery) {
    throwException();
    return super.deleteByQuery(index, deleteQuery);
}
 
Example #13
Source File: EsIndexImpl.java    From io with Apache License 2.0 4 votes vote down vote up
@Override
DeleteByQueryResponse doProcess() {
    return esClient.deleteByQuery(name, deleteQuery);
}
 
Example #14
Source File: EsRetryTest.java    From io with Apache License 2.0 4 votes vote down vote up
@Override
public DeleteByQueryResponse deleteByQuery(String index, QueryBuilder deleteQuery) {
    throwException();
    return super.deleteByQuery(index, deleteQuery);
}
 
Example #15
Source File: EsRetryTest.java    From io with Apache License 2.0 4 votes vote down vote up
@Override
public DeleteByQueryResponse deleteByQuery(String index, QueryBuilder deleteQuery) {
    throwException();
    return super.deleteByQuery(index, deleteQuery);
}
 
Example #16
Source File: EsRetryTest.java    From io with Apache License 2.0 4 votes vote down vote up
@Override
public DeleteByQueryResponse deleteByQuery(String index, QueryBuilder deleteQuery) {
    throwException();
    return super.deleteByQuery(index, deleteQuery);
}
 
Example #17
Source File: EsRetryTest.java    From io with Apache License 2.0 4 votes vote down vote up
@Override
public DeleteByQueryResponse deleteByQuery(String index, QueryBuilder deleteQuery) {
    throwException();
    return super.deleteByQuery(index, deleteQuery);
}
 
Example #18
Source File: EsRetryTest.java    From io with Apache License 2.0 4 votes vote down vote up
@Override
public DeleteByQueryResponse deleteByQuery(String index, QueryBuilder deleteQuery) {
    throwException();
    return super.deleteByQuery(index, deleteQuery);
}
 
Example #19
Source File: EsRetryTest.java    From io with Apache License 2.0 4 votes vote down vote up
@Override
public DeleteByQueryResponse deleteByQuery(String index, QueryBuilder deleteQuery) {
    throwException();
    return super.deleteByQuery(index, deleteQuery);
}
 
Example #20
Source File: Search.java    From elasticsearch-rest-command with The Unlicense 4 votes vote down vote up
public void executeDelete(ActionListener<DeleteByQueryResponse> listener) {
	deleteSearch.execute(listener);
}
 
Example #21
Source File: EsRetryTest.java    From io with Apache License 2.0 4 votes vote down vote up
@Override
public DeleteByQueryResponse deleteByQuery(String index, QueryBuilder deleteQuery) {
    throwException();
    return super.deleteByQuery(index, deleteQuery);
}
 
Example #22
Source File: EsIndexImpl.java    From io with Apache License 2.0 4 votes vote down vote up
@Override
DeleteByQueryResponse doProcess() {
    return esClient.deleteByQuery(name, deleteQuery);
}
 
Example #23
Source File: DeleteByQueryRequestBuilder.java    From elasticshell with Apache License 2.0 4 votes vote down vote up
@Override
protected ActionFuture<DeleteByQueryResponse> doExecute(DeleteByQueryRequest request) {
    return client.deleteByQuery(request);
}
 
Example #24
Source File: InternalEsClient.java    From io with Apache License 2.0 2 votes vote down vote up
/**
 * 指定されたクエリを使用してデータの削除を行う.
 * @param index 削除対象のインデックス
 * @param deleteQuery 削除対象を指定するクエリ
 * @return ES応答
 */
public DeleteByQueryResponse deleteByQuery(String index, QueryBuilder deleteQuery) {
    DeleteByQueryResponse response = esTransportClient.prepareDeleteByQuery(index)
            .setQuery(deleteQuery).execute().actionGet();
    return response;
}