Search in sources :

Example 1 with UpdateResponse

use of org.opensearch.action.update.UpdateResponse 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)1 FessConfig (org.codelibs.fess.mylasta.direction.FessConfig)1 OpenSearchException (org.opensearch.OpenSearchException)1 UpdateRequestBuilder (org.opensearch.action.update.UpdateRequestBuilder)1 UpdateResponse (org.opensearch.action.update.UpdateResponse)1