您的位置:首页 > 其它

elasticsearch aggregation 过程(未完)

2017-09-08 13:21 405 查看
在查询过程中,ES是将整个查询分成几个阶段的,大体如下:QueryPhase

rescorePhase

suggestPhase

aggregationPhase

FetchPhase

对于全文检索,可能还有DFSPhase。从源代码QueryPhase 类可以看出
@Override
public void execute(SearchContext searchContext) throws QueryPhaseExecutionException {
//创建AggregationContext,
//初始化所有的Aggregator
aggregationPhase.preProcess(searchContext);
//实际query,还有聚合操作其实是在这部完成的
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);
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息