Search in sources :

Example 1 with SearchEngineClientException

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

the class SearchHelper method bulkUpdate.

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

Example 2 with SearchEngineClientException

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

the class SearchHelper method update.

public boolean update(final String id, final Consumer<UpdateRequestBuilder> builderLambda) {
    try {
        final FessConfig fessConfig = ComponentUtil.getFessConfig();
        final UpdateRequestBuilder builder = ComponentUtil.getSearchEngineClient().prepareUpdate().setIndex(fessConfig.getIndexDocumentUpdateIndex()).setId(id);
        builderLambda.accept(builder);
        final UpdateResponse response = builder.execute().actionGet(fessConfig.getIndexIndexTimeout());
        return response.getResult() == Result.CREATED || response.getResult() == Result.UPDATED;
    } catch (final OpenSearchException e) {
        throw new SearchEngineClientException("Failed to update doc  " + id, e);
    }
}
Also used : UpdateResponse(org.opensearch.action.update.UpdateResponse) SearchEngineClientException(org.codelibs.fess.es.client.SearchEngineClientException) UpdateRequestBuilder(org.opensearch.action.update.UpdateRequestBuilder) OpenSearchException(org.opensearch.OpenSearchException) FessConfig(org.codelibs.fess.mylasta.direction.FessConfig)

Aggregations

SearchEngineClientException (org.codelibs.fess.es.client.SearchEngineClientException)2 ExecutionException (java.util.concurrent.ExecutionException)1 FessConfig (org.codelibs.fess.mylasta.direction.FessConfig)1 OpenSearchException (org.opensearch.OpenSearchException)1 BulkRequestBuilder (org.opensearch.action.bulk.BulkRequestBuilder)1 BulkResponse (org.opensearch.action.bulk.BulkResponse)1 UpdateRequestBuilder (org.opensearch.action.update.UpdateRequestBuilder)1 UpdateResponse (org.opensearch.action.update.UpdateResponse)1