当前位置:网站首页>What did the DFS phase do
What did the DFS phase do
2022-07-03 07:30:00 【chuanyangwang】
/**
* Dfs phase of a search request, used to make scoring 100% accurate by collecting additional info from each shard before the query phase.
* The additional information is used to better compare the scores coming from all the shards, which depend on local factors (e.g. idf)
*/
public class DfsPhase implements SearchPhase {
@Override
public void preProcess(SearchContext context) {
}
@Override
public void execute(SearchContext context) {
try {
ObjectObjectHashMap<String, CollectionStatistics> fieldStatistics = HppcMaps.newNoNullKeysMap();
Map<Term, TermStatistics> stats = new HashMap<>();
IndexSearcher searcher = new IndexSearcher(context.searcher().getIndexReader()) {
@Override
public TermStatistics termStatistics(Term term, int docFreq, long totalTermFreq) throws IOException {
if (context.isCancelled()) {
throw new TaskCancelledException("cancelled");
}
TermStatistics ts = super.termStatistics(term, docFreq, totalTermFreq);
if (ts != null) {
stats.put(term, ts);
}
return ts;
}
@Override
public CollectionStatistics collectionStatistics(String field) throws IOException {
if (context.isCancelled()) {
throw new TaskCancelledException("cancelled");
}
CollectionStatistics cs = super.collectionStatistics(field);
if (cs != null) {
fieldStatistics.put(field, cs);
}
return cs;
}
};
searcher.createWeight(context.searcher().rewrite(context.query()), ScoreMode.COMPLETE, 1);
for (RescoreContext rescoreContext : context.rescore()) {
for (Query query : rescoreContext.getQueries()) {
searcher.createWeight(context.searcher().rewrite(query), ScoreMode.COMPLETE, 1);
}
}
Term[] terms = stats.keySet().toArray(new Term[0]);
TermStatistics[] termStatistics = new TermStatistics[terms.length];
for (int i = 0; i < terms.length; i++) {
termStatistics[i] = stats.get(terms[i]);
}
context.dfsResult().termsStatistics(terms, termStatistics)
.fieldStatistics(fieldStatistics)
.maxDoc(context.searcher().getIndexReader().maxDoc());
} catch (Exception e) {
throw new DfsPhaseExecutionException(context.shardTarget(), "Exception during dfs phase", e);
}
}
}dfs Stage collect the statistical information of the word items of each segment . The method of collection is to use createWeight Two methods called when
- termStatistics
- collectionStatistics
org.elasticsearch.search.SearchService#executeQueryPhase(org.elasticsearch.search.query.QuerySearchRequest, org.elasticsearch.action.search.SearchShardTask, org.elasticsearch.action.ActionListener<org.elasticsearch.search.query.QuerySearchResult>)
public void executeQueryPhase(QuerySearchRequest request, SearchShardTask task, ActionListener<QuerySearchResult> listener) {
runAsync(request.id(), () -> {
final SearchContext context = findContext(request.id(), request);
context.setTask(task);
context.incRef();
try (SearchOperationListenerExecutor executor = new SearchOperationListenerExecutor(context)) {
contextProcessing(context);
// Will be obtained in the previous round dfs Put in aggregatedDfs in
context.searcher().setAggregatedDfs(request.dfs());
queryPhase.execute(context);
if (context.queryResult().hasSearchContext() == false && context.scrollContext() == null) {
// no hits, we can release the context since there will be no fetch phase
freeContext(context.id());
} else {
contextProcessedSuccessfully(context);
}
executor.success();
return context.queryResult();
} catch (Exception e) {
logger.trace("Query phase failed", e);
processFailure(context, e);
throw e;
} finally {
cleanContext(context);
}
}, listener);
}dfs three
DFS_ACTION_NAME obtain dfs Information
QUERY_ID_ACTION_NAME take dfs The information is transmitted to each segment , And do query
FETCH_ID_ACTION_NAME fetch
边栏推荐
- Rabbit MQ message sending of vertx
- Recursion, Fibonacci sequence
- The embodiment of generics in inheritance and wildcards
- 树莓派更新工具链
- C WinForm framework
- Interview questions about producers and consumers (important)
- Beginners use Minio
- 2021-07-18
- Some experiences of Arduino soft serial port communication
- 昇思MindSpore再升级,深度科学计算的极致创新
猜你喜欢

带你全流程,全方位的了解属于测试的软件事故
![[coppeliasim4.3] C calls UR5 in the remoteapi control scenario](/img/ca/2f72ea3590c358a6c9884aaa1a1c33.png)
[coppeliasim4.3] C calls UR5 in the remoteapi control scenario

Custom generic structure

不出网上线CS的各种姿势

Pat grade a real problem 1166

691. Cube IV

docker建立mysql:5.7版本指定路径挂载不上。

Dora (discover offer request recognition) process of obtaining IP address

Hash table, generic

VMWare网络模式-桥接,Host-Only,NAT网络
随机推荐
Le Seigneur des anneaux: l'anneau du pouvoir
Take you through the whole process and comprehensively understand the software accidents that belong to testing
docker建立mysql:5.7版本指定路径挂载不上。
691. Cube IV
Deep learning parameter initialization (I) Xavier initialization with code
Use of file class
Leetcode 198: house raiding
OSI knowledge sorting
论文学习——鄱阳湖星子站水位时间序列相似度研究
【CMake】CMake链接SQLite库
Margin left: -100% understanding in the Grail layout
【无标题】
twenty million two hundred and twenty thousand three hundred and nineteen
【已解决】SQLException: Invalid value for getInt() - ‘田鹏‘
II. D3.js draw a simple figure -- circle
IP home online query platform
Arduino Serial系列函数 有关print read 的总结
Sent by mqtt client server of vertx
Operation and maintenance technical support personnel have hardware maintenance experience in Hong Kong
Common APIs