在查询过程中,ES是将整个查询分成几个阶段的,大体如下:
-
QueryPhase
-
rescorePhase
-
suggestPhase
-
aggregationPhase
-
FetchPhase
对于全文检索,可能还有DFSPhase。从源代码QueryPhase 类可以看出
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
@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);
}
}
|
本文转自whk66668888 51CTO博客,原文链接:http://blog.51cto.com/12597095/1963663