org.elasticsearch.action.get.MultiGetRequestBuilder Java Examples

The following examples show how to use org.elasticsearch.action.get.MultiGetRequestBuilder. 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: ElasticsearchClient.java    From yacy_grid_mcp with GNU Lesser General Public License v2.1 5 votes vote down vote up
private Map<String, Map<String, Object>> readMapBulkInternal(final String indexName, final Collection<String> ids) {
    MultiGetRequestBuilder mgrb = elasticsearchClient.prepareMultiGet();
    ids.forEach(id -> mgrb.add(indexName, null, id).execute().actionGet());
    MultiGetResponse response = mgrb.execute().actionGet();
    Map<String, Map<String, Object>> bulkresponse = new HashMap<>();
    for (MultiGetItemResponse r: response.getResponses()) {
        GetResponse gr = r.getResponse();
        if (gr != null) {
            Map<String, Object> map = getMap(gr);
            bulkresponse.put(r.getId(), map);
        }
    }
    return bulkresponse;
}
 
Example #2
Source File: ClientWithStats.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public MultiGetRequestBuilder prepareMultiGet() {
	return wrapped.prepareMultiGet();
}
 
Example #3
Source File: DefaultElasticSearchService.java    From vertx-elasticsearch-service with Apache License 2.0 4 votes vote down vote up
@Override
public void multiGet(final List<MultiGetQueryOptions> multiGetQueryOptions,
                     final MultiGetOptions options,
                     final Handler<AsyncResult<com.hubrick.vertx.elasticsearch.model.MultiGetResponse>> resultHandler) {

    final MultiGetRequestBuilder builder = client.prepareMultiGet();

    if (options != null) {
        if (options.getRefresh() != null) {
            builder.setRefresh(options.getRefresh());
        }
        if (options.getRealtime() != null) {
            builder.setRealtime(options.getRealtime());
        }
        if (options.getPreference() != null) {
            builder.setPreference(options.getPreference());
        }
    }

    for (MultiGetQueryOptions multiGetQueryOptionsItem : multiGetQueryOptions) {
        final MultiGetRequest.Item item = new MultiGetRequest.Item(multiGetQueryOptionsItem.getIndex(), multiGetQueryOptionsItem.getType(), multiGetQueryOptionsItem.getId());
        if (multiGetQueryOptionsItem.getParent() != null) item.parent(multiGetQueryOptionsItem.getParent());
        if (multiGetQueryOptionsItem.getRouting() != null) item.routing(multiGetQueryOptionsItem.getRouting());
        if (multiGetQueryOptionsItem.getStoredFields() != null)
            item.storedFields(multiGetQueryOptionsItem.getStoredFields().toArray(new String[0]));
        if (multiGetQueryOptionsItem.getFetchSource() != null) {
            item.fetchSourceContext(
                    new FetchSourceContext(
                            multiGetQueryOptionsItem.getFetchSource(),
                            multiGetQueryOptionsItem.getFetchSourceIncludes().toArray(new String[0]),
                            multiGetQueryOptionsItem.getFetchSourceExcludes().toArray(new String[0])
                    )
            );
        }

        builder.add(item);
    }

    builder.execute(new ActionListener<MultiGetResponse>() {
        @Override
        public void onResponse(final MultiGetResponse multiGetResponse) {
            resultHandler.handle(Future.succeededFuture(mapToMultiGetResponse(multiGetResponse)));
        }

        @Override
        public void onFailure(final Exception e) {
            handleFailure(resultHandler, e);
        }
    });
}
 
Example #4
Source File: IndexThread.java    From disthene with MIT License 4 votes vote down vote up
public MultiGetRequestBuilder add(Metric metric) {
    metrics.put(metric.getId(), metric);
    return super.add(index, type, metric.getId());
}
 
Example #5
Source File: FessEsClient.java    From fess with Apache License 2.0 4 votes vote down vote up
@Override
public MultiGetRequestBuilder prepareMultiGet() {
    return client.prepareMultiGet();
}