# 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-最终的正排索引与倒排索引的更多相关文章

  1. 后端程序员之路 32、Index搜索引擎实现分析1-类的设计

    # 1.forward_index 正排索引(正向索引)- filter_t- filter_judge # 2.inverted_index 倒排索引(反向索引)- inverted_pre_sco ...

  2. 后端程序员之路 33、Index搜索引擎实现分析2-对外接口和大体流程

    # index_manager的单例是index server对外的唯一接口,part_indexer是index搜索的核心部分,index_manager持有了一组part_indexer. typ ...

  3. 后端程序员之路 34、Index搜索引擎实现分析3-对文章索引的两层分块

    # part_indexer 对文章根据id的hash进行分块索引- 持有 search_index _inc_index[2]; search_index _history_index[2]; 进行 ...

  4. 后端程序员之路 43、Redis list

    Redis数据类型之LIST类型 - Web程序猿 - 博客频道 - CSDN.NEThttp://blog.csdn.net/thinkercode/article/details/46565051 ...

  5. 后端程序员之路 13、使用KNN进行数字识别

    尝试一些用KNN来做数字识别,测试数据来自:MNIST handwritten digit database, Yann LeCun, Corinna Cortes and Chris Burgesh ...

  6. 后端程序员之路 59、go uiprogress

    gosuri/uiprogress: A go library to render progress bars in terminal applicationshttps://github.com/g ...

  7. 后端程序员之路 31、Protocol Buffer

    google/protobuf: Protocol Buffers - Google's data interchange formathttps://github.com/google/protob ...

  8. 后端程序员之路 22、RESTful API

    理解RESTful架构 - 阮一峰的网络日志http://www.ruanyifeng.com/blog/2011/09/restful.html RESTful API 设计指南 - 阮一峰的网络日 ...

  9. 后端程序员之路 16、信息熵 、决策树、ID3

    信息论的熵 - guisu,程序人生. 逆水行舟,不进则退. - 博客频道 - CSDN.NEThttp://blog.csdn.net/hguisu/article/details/27305435 ...

随机推荐

  1. Java正则表达式解析网页源码

    <!DOCTYPE html> <html lang="zh-Hans"> <head> <meta charset="utf- ...

  2. MySQL常用SQL语句1

    -- 创建表 CREATE TABLE USER ( -- id默认每个表都该拥有(非空 不重复) -- (id是每一行的唯一标识) -- 其他字段可能会重复,我们无法依赖其他的字段去确定某一行记录 ...

  3. CF 1244 C - The Football Season

    C - The Football Season 先考虑求解 \[ x\times w + y\times d=p \] 若存在一组解 \[ \begin{cases} x_0\\ y_0 = kw + ...

  4. BZOJ3238 [Ahoi2013]差异 【SAM or SA】

    BZOJ3238 [Ahoi2013]差异 给定一个串,问其任意两个后缀的最长公共前缀长度的和 1.又是后缀,又是\(lcp\),很显然直接拿\(SA\)的\(height\)数组搞就好了,配合一下单 ...

  5. Luogu T10025 排列名次

    题目链接 题目描述 给定一个长度为n的排列,要求输出该排列的字典序名次(1,2,3,...,n的名次为1). 输入输出格式 输入格式: 第一行一个数n,表示排列长度. 第二行n个数,用空格分隔,表示一 ...

  6. 灯光照射,圆形探测类问题(解题报告)<分层差分><cmath取整>

    题目描述 一个n*n的网格图上有m个探测器,每个探测器有个探测半径r,问这n*n个点中有多少个点能被探测到. 输入输出格式 输入格式: (1<=r<n<=5000) (1<=m ...

  7. 牛客小白月赛30 B.最好的宝石 (线段树)

    题意:RT. 题解:很明显的线段树维护区间最大值操作,但是我们同时还要维护最大值的个数,我们在build或者modify操作完子树然后push_up的时候,我们先从两个儿子取max更新父节点的最大值, ...

  8. Codeforces Round #531 (Div. 3) C. Doors Breaking and Repairing (博弈)

    题意:有\(n\)扇门,你每次可以攻击某个门,使其hp减少\(x\)(\(\le 0\)后就不可修复了),之后警察会修复某个门,使其hp增加\(y\),问你最多可以破坏多少扇门? 题解:首先如果\(x ...

  9. OpenStack Train版-15.创建并挂载存储卷

    1.创建并挂载存储卷 创建一个1GB的卷 source ~/demo-openrc openstack volume create --size 1 volume1 很短的时间后,卷状态应该从crea ...

  10. C++ part7

    1.C++ 继承和组合 类的组合和继承一样,是复用的重要方式. 要优先使用组合而不是继承. 原因: 组合是黑箱复用,对局部类的内部细节不可见:继承是白箱复用,父类的内部细节可见,破坏封装性. 继承在编 ...