Пример #1
0
 public final ImmutableList<ModelEntryT> getModels(
     final Logger logger,
     final Marker logMarker,
     final ModelFactory<ModelEntryT> modelFactory,
     final SearchRequestBuilder requestBuilder)
     throws IoExceptionT {
   checkNotNull(requestBuilder);
   try {
     logger.debug(logMarker, "searching index {} with {}", indexName, requestBuilder);
     final SearchResponse response = requestBuilder.execute().actionGet();
     final ImmutableList.Builder<ModelEntryT> modelsBuilder = ImmutableList.builder();
     for (final SearchHit searchHit : response.getHits()) {
       try {
         modelsBuilder.add(
             modelFactory.createModelEntry(searchHit.getId(), searchHit.getSourceRef()));
       } catch (final InvalidModelException e) {
         logger.error(logMarker, "invalid model {} from index, ignoring: ", searchHit.getId(), e);
         continue;
       }
     }
     return modelsBuilder.build();
   } catch (final IndexNotFoundException e) {
     throw e;
   } catch (final ElasticsearchException e) {
     logger.error(
         logMarker, "error searching models on index {} with {}: ", indexName, requestBuilder, e);
     throw exceptionFactory.newIoException(
         e,
         String.format("error searching models on index %s with '%s'", indexName, requestBuilder));
   }
 }
 public ClientHit(SearchHit delegate) {
   this.delegate = delegate;
   source = delegate.hasSource() ? null : delegate.getSourceRef();
 }