ElasticSearchTypeImpl implements ElasticSearchType<T> { @Override public SearchResponse<T> search(SearchRequest request) { var watch = new StopWatch(); validate(request); long esTook = 0; String index = request.index == null ? this.index : request.index; int hits = 0; try { var searchRequest = searchRequest(index); if (request.type != null) searchRequest.searchType(request.type); SearchSourceBuilder source = searchRequest.source().query(request.query); request.aggregations.forEach(source::aggregation); request.sorts.forEach(source::sort); if (request.skip != null) source.from(request.skip); if (request.limit != null) source.size(request.limit); if (request.trackTotalHitsUpTo != null) source.trackTotalHitsUpTo(request.trackTotalHitsUpTo); org.elasticsearch.action.search.SearchResponse response = search(searchRequest); esTook = response.getTook().nanos(); hits = response.getHits().getHits().length; return searchResponse(response); } catch (IOException e) { throw new UncheckedIOException(e); } finally { long elapsed = watch.elapsed(); ActionLogContext.track("elasticsearch", elapsed, hits, 0); logger.debug("search, hits={}, esTook={}, elapsed={}", hits, esTook, elapsed); checkSlowOperation(elapsed); } } ElasticSearchTypeImpl(ElasticSearchImpl elasticSearch, Class<T> documentClass); @Override SearchResponse<T> search(SearchRequest request); @Override List<String> complete(CompleteRequest request); @Override Optional<T> get(GetRequest request); @Override void index(IndexRequest<T> request); @Override void bulkIndex(BulkIndexRequest<T> request); @Override void update(UpdateRequest<T> request); @Override boolean delete(DeleteRequest request); @Override void bulkDelete(BulkDeleteRequest request); @Override List<String> analyze(AnalyzeRequest request); @Override void forEach(ForEach<T> forEach);  }
@Test void search() { var request = new SearchRequest(); request.skip = 99; request.limit = 10; assertThatThrownBy(() -> searchType.search(request)) .isInstanceOf(Error.class) .hasMessageContaining("result window is too large"); }