当前位置:网站首页>filter执行原理深度剖析(bitset机制与caching机制)
filter执行原理深度剖析(bitset机制与caching机制)
2022-04-22 17:54:00 【打分几楼MOTO】
- 在倒排索引中查找搜索串,获取document list
| word | doc1 | doc2 | doc3 |
| 2017-01-01 | * | * | |
| 2017-01-02 | * | * | |
| 2017-01-03 | * | * | * |
filter:2017-01-02 ====>到倒排索引中一找,发现2017-01-02对应的document list 为 doc1 doc2
- 为每个倒排索引中搜索到的结果,构建一个bitset[1,1,0,0,0]
- 使用找到的 doc list,构建一个bitset,就是一个二进制数组(尽可能用简单的数据结构实现复杂的功能),数组每个元素都是0或者1,用来表示一个doc对一个filter条件是否匹配,如果匹配就是1,不匹配就是0
- filter:2017-01-02 ===> [0,1,1] ==>doc1不匹配,doc2和doc3匹配
- 遍历每个过滤条件的对应的bitset,优先从最稀疏的开始搜索,先过滤掉尽可能多的数据,查找满足所有条件的document
- caching bitset, 跟踪query,在最近256个query中超过一定条件的过滤条件,缓存其bitset.对于小segment(<1000或者<3%),不缓存bitset(segment数据量很小,此时哪怕是扫描也很快;segment会在后台自动合并,小segment很快会跟其他小segment合并成打segment,此时缓存也没有扫描意义)
- filter在query之前执行,先尽量过滤掉尽可能多的数据
- 如果document有新增或者修改,那么cached bitset会被自动更新
- 缓存会自动更新:如果 postData=2017-01-01:[0,0,0,1].此时documentId为5也符合这个条件,那么会自动更新到postData=2017-01-01这个filter的bitset中[0,0,0,1,1]
- 以后只要有相同的filter条件的,会直接来使用这个过滤条件对应的cached bitset的
比较复杂的Demo
查询articleId为2222,或者articleId为1111而且日期为2017
{
"query":{
"constant_score":{
"filter":{
"bool":{
"should":[
{"term" : {"articleId" : "2222"}},
{"bool" :
"must":[
{"term":{"articleId":"1111"}},
{"term":{"postDate":"2017"}},
]
}
]
}
}
}
}
}
版权声明
本文为[打分几楼MOTO]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_44447372/article/details/124350091
边栏推荐
- APP应该关注哪些数据指标?
- 常见报错记录
- Multithreaded notes | future interface function
- L1-002 printing Hourglass (20 points)
- Sunyuchen announced the launch of usdd to promote financial freedom
- tbb concurrent_ multiset/concurrent_ set unsafe_ Erase() crash
- 嵌入式设计与开发项目-数码管静态显示程序设计
- L1-025 positive integer a + B (15 points)
- MySQL排序与分页
- Guiyitong appointment registration
猜你喜欢

Daily practice - day 1 -3.18

Spacy first routine (automatic annotation of Chinese text)

Qiu Chengtong has joined Tsinghua full time

CISP 考试资源分享

Soft test high item notes | project schedule management

Guiyitong appointment registration

How does the usdd anchored to the US dollar lead the transformation of digital currency

Common libraries for video playback

Knowing that it is inevitable to break the listing in Hong Kong: Zhou Yuan was "beaten in the face", and the growth is extremely dependent on marketing

软考高项笔记 | 软技能
随机推荐
软考高项笔记 | 软件集成技术
CISP examination resource sharing
软考高项笔记 | 国家信息化体系六要素
2022年,5G芯片会有哪些值得期待的发展趋势?
软考高项笔记 | 需求分类
软考高项笔记 | 立项管理内容
多线程笔记 | 比对 Thread 和 Runnable
This is perhaps the most detailed summary of machine learning model fusion methods
软考高项笔记 | 信息化的五个层次
Unable to translate SQLException with Error code ‘0‘, will now try the fallback translator
微软的软件工程生命周期
Must brush the simulated question bank and answers of the latest eight members of Jiangxi in 2022
pr导出的avi文件,如何才能被imageJ读read?
National Information Exchange Model(NIEM)操作手册
Soft test high item notes | basis of project evaluation
Why has Sony always dominated the smartphone sensor market
软考高项笔记 | 项目进度管理
spaCy教程学习
spaCy第一个例程(中文文本自动标注)
邮箱格式测试