Search in sources :

Example 1 with FessEsClientException

use of org.codelibs.fess.es.client.FessEsClientException in project fess by codelibs.

the class SearchService method update.

public boolean update(final String id, final Consumer<UpdateRequestBuilder> builderLambda) {
    try {
        final UpdateRequestBuilder builder = fessEsClient.prepareUpdate(fessConfig.getIndexDocumentUpdateIndex(), fessConfig.getIndexDocumentType(), id);
        builderLambda.accept(builder);
        final UpdateResponse response = builder.execute().actionGet(fessConfig.getIndexIndexTimeout());
        return response.getResult() == Result.CREATED || response.getResult() == Result.UPDATED;
    } catch (final ElasticsearchException e) {
        throw new FessEsClientException("Failed to update doc  " + id, e);
    }
}
Also used : UpdateResponse(org.elasticsearch.action.update.UpdateResponse) UpdateRequestBuilder(org.elasticsearch.action.update.UpdateRequestBuilder) FessEsClientException(org.codelibs.fess.es.client.FessEsClientException) ElasticsearchException(org.elasticsearch.ElasticsearchException)

Example 2 with FessEsClientException

use of org.codelibs.fess.es.client.FessEsClientException in project fess by codelibs.

the class SearchService method bulkUpdate.

public boolean bulkUpdate(final Consumer<BulkRequestBuilder> consumer) {
    final BulkRequestBuilder builder = fessEsClient.prepareBulk();
    consumer.accept(builder);
    try {
        final BulkResponse response = builder.execute().get();
        if (response.hasFailures()) {
            throw new FessEsClientException(response.buildFailureMessage());
        } else {
            return true;
        }
    } catch (InterruptedException | ExecutionException e) {
        throw new FessEsClientException("Failed to update bulk data.", e);
    }
}
Also used : FessEsClientException(org.codelibs.fess.es.client.FessEsClientException) BulkResponse(org.elasticsearch.action.bulk.BulkResponse) BulkRequestBuilder(org.elasticsearch.action.bulk.BulkRequestBuilder) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

FessEsClientException (org.codelibs.fess.es.client.FessEsClientException)2 ExecutionException (java.util.concurrent.ExecutionException)1 ElasticsearchException (org.elasticsearch.ElasticsearchException)1 BulkRequestBuilder (org.elasticsearch.action.bulk.BulkRequestBuilder)1 BulkResponse (org.elasticsearch.action.bulk.BulkResponse)1 UpdateRequestBuilder (org.elasticsearch.action.update.UpdateRequestBuilder)1 UpdateResponse (org.elasticsearch.action.update.UpdateResponse)1