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);
}
}
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);
}
}
Aggregations