use of org.sonar.server.es.searchrequest.RequestFiltersComputer in project sonarqube by SonarSource.
the class ProjectMeasuresIndex method search.
public SearchIdResult<String> search(ProjectMeasuresQuery query, SearchOptions searchOptions) {
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder().fetchSource(false).trackTotalHits(true).from(searchOptions.getOffset()).size(searchOptions.getLimit());
AllFilters allFilters = createFilters(query);
RequestFiltersComputer filtersComputer = createFiltersComputer(searchOptions, allFilters);
addFacets(searchSourceBuilder, searchOptions, filtersComputer, query);
addSort(query, searchSourceBuilder);
filtersComputer.getQueryFilters().ifPresent(searchSourceBuilder::query);
filtersComputer.getPostFilters().ifPresent(searchSourceBuilder::postFilter);
SearchResponse response = client.search(EsClient.prepareSearch(TYPE_PROJECT_MEASURES.getMainType()).source(searchSourceBuilder));
return new SearchIdResult<>(response, id -> id, system2.getDefaultTimeZone().toZoneId());
}
use of org.sonar.server.es.searchrequest.RequestFiltersComputer in project sonarqube by SonarSource.
the class ProjectMeasuresIndex method addFacets.
private static void addFacets(SearchSourceBuilder esRequest, SearchOptions options, RequestFiltersComputer filtersComputer, ProjectMeasuresQuery query) {
TopAggregationHelper topAggregationHelper = new TopAggregationHelper(filtersComputer, new SubAggregationHelper());
options.getFacets().stream().map(FACETS_BY_NAME::get).filter(Objects::nonNull).map(facet -> facet.getFacetBuilder().buildFacet(facet, query, topAggregationHelper)).forEach(esRequest::aggregation);
}
use of org.sonar.server.es.searchrequest.RequestFiltersComputer in project sonarqube by SonarSource.
the class IssueIndex method search.
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);
}
use of org.sonar.server.es.searchrequest.RequestFiltersComputer in project sonarqube by SonarSource.
the class IssueIndex method configureQuery.
private static void configureQuery(SearchSourceBuilder esRequest, RequestFiltersComputer filterComputer) {
QueryBuilder esQuery = filterComputer.getQueryFilters().map(t -> (QueryBuilder) boolQuery().must(matchAllQuery()).filter(t)).orElse(matchAllQuery());
esRequest.query(esQuery);
}
Aggregations