后端程序员之路 35、Index搜索引擎实现分析4-最终的正排索引与倒排索引
# index_box 提供搜索功能的实现
- 持有std::vector<ITEM> _buffer; 存储所有文章信息
- 持有ForwardIndex _forward_index;
- _forward_index.build_findex( _buffer )
- get_all_items _forward_index.get_all_items
- get_items _forward_index.get_items(docid_vect, result, filters);
- get_item _forward_index.get_item
- 持有InvertedIndex _inverted_index;
- _inverted_index.build_iindex( _forward_index.get_forword_index() );
- search _inverted_index.trigger(docid_result, working_vect, docid_set, user_profile, search_params);
# ForwardIndex 正排索引(正向索引)
- 持有boost::unordered_map<uint64_t, ITEM> _id2docitem
- 持有boost::unordered_map<uint64_t, filter_t> _id2filter;
- 持有boost::unordered_map<uint64_t, bool> _blacklist;
- build_findex
- 已删除的文章从_id2docitem、_id2filter删除,加入到_blacklist
- 更新黑名单,把已更新的文章从_blacklist删除
- 已过期文章加入_blacklist,从_id2docitem、_id2filter删除
- 加入新文章或者更新后的文章到_id2docitem、_id2filter
- get_all_items 返回_id2docitem的数据
- get_item 返回_id2docitem.find
- get_items 处理filters,然后_id2docitem.find
- filter_ids 根据FilterJudge和search_params_t对文章进行过滤
# InvertedIndex 倒排索引(反向索引)
- boost::unordered_map<uint64_t, docid_vect_t > inverted_index_t; 从key到文章数组的映射
- std::vector<inverted_index_t> multi_inverted_index_t; 多个从key到文章数组的映射
- 内置
- build_iindex
- 建立category、keyword、topic、ventity等到docid的索引
- 对数据的vector根据打分进行排序
- trigger
- 构造working_vect,用于整个流程放置文章集
- 进行一系列的trigger_by_features
- 从一系列特征找到一系列文章vect
- 找到的文章进行union_insert,合并到working_vect
- 进行一系列的trigger_or_keys
- 基本同trigger_by_features
- 对working_vect里的文章进行check_intersection,即匹配更多and/no操作,得到最终docid_vect
后端程序员之路 35、Index搜索引擎实现分析4-最终的正排索引与倒排索引的更多相关文章
- 后端程序员之路 32、Index搜索引擎实现分析1-类的设计
# 1.forward_index 正排索引(正向索引)- filter_t- filter_judge # 2.inverted_index 倒排索引(反向索引)- inverted_pre_sco ...
- 后端程序员之路 33、Index搜索引擎实现分析2-对外接口和大体流程
# index_manager的单例是index server对外的唯一接口,part_indexer是index搜索的核心部分,index_manager持有了一组part_indexer. typ ...
- 后端程序员之路 34、Index搜索引擎实现分析3-对文章索引的两层分块
# part_indexer 对文章根据id的hash进行分块索引- 持有 search_index _inc_index[2]; search_index _history_index[2]; 进行 ...
- 后端程序员之路 43、Redis list
Redis数据类型之LIST类型 - Web程序猿 - 博客频道 - CSDN.NEThttp://blog.csdn.net/thinkercode/article/details/46565051 ...
- 后端程序员之路 13、使用KNN进行数字识别
尝试一些用KNN来做数字识别,测试数据来自:MNIST handwritten digit database, Yann LeCun, Corinna Cortes and Chris Burgesh ...
- 后端程序员之路 59、go uiprogress
gosuri/uiprogress: A go library to render progress bars in terminal applicationshttps://github.com/g ...
- 后端程序员之路 31、Protocol Buffer
google/protobuf: Protocol Buffers - Google's data interchange formathttps://github.com/google/protob ...
- 后端程序员之路 22、RESTful API
理解RESTful架构 - 阮一峰的网络日志http://www.ruanyifeng.com/blog/2011/09/restful.html RESTful API 设计指南 - 阮一峰的网络日 ...
- 后端程序员之路 16、信息熵 、决策树、ID3
信息论的熵 - guisu,程序人生. 逆水行舟,不进则退. - 博客频道 - CSDN.NEThttp://blog.csdn.net/hguisu/article/details/27305435 ...
随机推荐
- B - B Saruman's Army(贪心)
在一条直线上,有n个点.从这n个点中选择若干个,给他们加上标记.对于每一个点,其距离为R以内的区域里必须有一个被标记的点.问至少要有多少点被加上标记 Saruman the White must le ...
- UVA442 矩阵链乘 Matrix Chain Multiplication
题意: 这道题也是在不改变原序列每个元素位置的前提下,看每个元素与他身边的两个元素那个先结合能得到最大的能量 题解: 很明显这是一道区间dp的题目,这道题要断环成链,这道题需要考虑在这个区间上某个元素 ...
- UVALive 7276 Wooden Signs
详细题目见:http://7xjob4.com1.z0.glb.clouddn.com/0f10204481da21e62f8c145939e5828e 思路:记dp[i][j]表示第i个木板尾部在j ...
- Codeforces Round #544 (Div. 3) E. K Balanced Teams (DP)
题意:有\(n\)个人,每个人的能力值是\(a_i\),现在你想将这些人分成\(k\)组(没必要全选),但是每组中最高水平和最低水平的人的能力差值必须\(\le 5\),问最多能选多少人. 题解:想了 ...
- Codeforces Round #667 (Div. 3) E. Two Platforms (双指针)
题意:有\(n\)个点往下落,你可以在最下面放两个长度为\(k\)的板子,问做多能接到多少个点. 题解:这题给纵坐标\(y\)完全没有用,我们先对横坐标\(x\)排序,然后从左边开始枚举,用\(l[i ...
- RuntimeError already started
Env: os: Ubuntu python3 pytorch vscode Desc 在上述环境中运行A3C多进程模型,使用命令行时没问题,使用vscode时出现 'RuntimeError: al ...
- ElasticSearch 交互使用
Curl 命令 # 建立索引 [root@dbtest01 ~]# curl -XPUT 'http://10.0.0.121:9200/test' # 插入数据 [root@dbtest01 ~]# ...
- Hexo、主题、部署上线
Hexo.主题.部署上线 安装Hexo git和nodejs安装好后,就可以安装hexo了,你可以先创建一个文件夹MyBlog,用来存放自己的博客文件,然后cd到这个文件夹下(或者在这个文件夹下直接右 ...
- Python爬虫全网搜索并下载音乐
现在写一篇博客总是喜欢先谈需求或者本内容的应用场景,是的,如果写出来的东西没有任何应用价值,确实也没有实际意义.今天的最早的需求是来自于如何免费[白嫖]下载全网优质音乐,我去b站上面搜索到了一个大牛做 ...
- HTML script tag type all in one
HTML script tag type all in one script type https://developer.mozilla.org/en-US/docs/Web/HTML/Elemen ...