elasticsearch aggregation 過程(未完)
阿新 • • 發佈:2017-09-08
elasticsearch aggregation 過程
在查詢過程中,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); } }
elasticsearch aggregation 過程(未完)