public SearchResponse search(IssueQuery query, SearchOptions options) {
    SearchRequest requestBuilder = EsClient.prepareSearch(TYPE_ISSUE.getMainType());
    SearchSourceBuilder sourceBuilder = new SearchSourceBuilder();
    requestBuilder.source(sourceBuilder);

    configureSorting(query, sourceBuilder);
    configurePagination(options, sourceBuilder);
    configureRouting(query, options, requestBuilder);

    AllFilters allFilters = createAllFilters(query);
    RequestFiltersComputer filterComputer = newFilterComputer(options, allFilters);

    configureTopAggregations(query, options, sourceBuilder, allFilters, filterComputer);
    configureQuery(sourceBuilder, filterComputer);
    configureTopFilters(sourceBuilder, filterComputer);

    sourceBuilder.fetchSource(false)
      .trackTotalHits(true);

    return client.search(requestBuilder);
  }
@Test
  void search_exceeding_default_index_max_window() {
    ComponentDto project = newPrivateProjectDto();
    ComponentDto file = newFileDto(project);
    List<IssueDoc> issues = new ArrayList<>();
    for (int i = 0; i < 11_000; i++) {
      String key = "I" + i;
      issues.add(newDoc(key, project.uuid(), file));
    }
    indexIssues(issues.toArray(new IssueDoc[]{}));

    IssueQuery.Builder query = IssueQuery.builder();
    SearchResponse result = underTest.search(query.build(), new SearchOptions().setLimit(500));
    assertThat(result.getHits().getHits()).hasSize(SearchOptions.MAX_PAGE_SIZE);
    assertThat(result.getHits().getTotalHits().value).isEqualTo(11_000L);
    assertThat(result.getHits().getTotalHits().relation).isEqualTo(Relation.EQUAL_TO);
  }