Java Code Examples for org.elasticsearch.search.internal.SearchContext#getProfilers()
The following examples show how to use
org.elasticsearch.search.internal.SearchContext#getProfilers() .
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: QueryPhase.java From Elasticsearch with Apache License 2.0 | 6 votes |
@Override public void execute(SearchContext searchContext) throws QueryPhaseExecutionException { // Pre-process aggregations as late as possible. In the case of a DFS_Q_T_F // request, preProcess is called on the DFS phase phase, this is why we pre-process them // here to make sure it happens during the QUERY phase aggregationPhase.preProcess(searchContext); boolean rescore = execute(searchContext, searchContext.searcher()); if (rescore) { // only if we do a regular search rescorePhase.execute(searchContext); } suggestPhase.execute(searchContext); aggregationPhase.execute(searchContext); if (searchContext.getProfilers() != null) { List<ProfileShardResult> shardResults = Profiler.buildShardResults(searchContext.getProfilers().getProfilers()); searchContext.queryResult().profileResults(shardResults); } }
Example 2
Source File: AggregationPhase.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public void preProcess(SearchContext context) { if (context.aggregations() != null) { AggregationContext aggregationContext = new AggregationContext(context); context.aggregations().aggregationContext(aggregationContext); List<Aggregator> collectors = new ArrayList<>(); Aggregator[] aggregators; try { AggregatorFactories factories = context.aggregations().factories(); aggregators = factories.createTopLevelAggregators(aggregationContext); for (int i = 0; i < aggregators.length; i++) { if (aggregators[i] instanceof GlobalAggregator == false) { collectors.add(aggregators[i]); } } context.aggregations().aggregators(aggregators); if (!collectors.isEmpty()) { Collector collector = BucketCollector.wrap(collectors); ((BucketCollector)collector).preCollection(); if (context.getProfilers() != null) { // TODO: report on child aggs as well List<InternalProfileCollector> emptyList = Collections.emptyList(); collector = new InternalProfileCollector(collector, CollectorResult.REASON_AGGREGATION, emptyList); } context.queryCollectors().put(AggregationPhase.class, collector); } } catch (IOException e) { throw new AggregationInitializationException("Could not initialize aggregators", e); } } }