当前位置:网站首页>搜索 正排索引 和 倒排索引 区别
搜索 正排索引 和 倒排索引 区别
2022-07-05 15:48:00 【软件工程小施同学】
一、什么是正排索引(forward index)?
简言之,由key查询实体的过程,使用正排索引。
例如,用户表:
t_user(uid, name, passwd, age, sex)
由uid查询整行的过程,就是正排索引查询。
画外音:时间复杂度可以认为是O(1)。
二、什么是倒排索引(inverted index)?
与正排索引相反,由item查询key的过程,使用倒排索引。
对于网页搜索,倒排索引可以理解为:
Map<item, list<url>>
能够由查询词快速找到包含这个查询词的网页的数据结构。
画外音:时间复杂度也是O(1)。
举个例子,假设有3个网页:
url1 -> “我爱北京”
url2 -> “我爱到家”
url3 -> “到家美好”
这是一个正排索引:
Map<url, page_content>。
分词之后:
url1 -> {我,爱,北京}
url2 -> {我,爱,到家}
url3 -> {到家,美好}
这是一个分词后的正排索引:
Map<url, list<item>>。
分词后倒排索引:
我 -> {url1, url2}
爱 -> {url1, url2}
北京 -> {url1}
到家 -> {url2, url3}
美好 -> {url3}
由检索词item快速找到包含这个查询词的网页Map<item, list<url>>就是倒排索引。
画外音:明白了吧,词到url的过程,是倒排索引。
正排索引和倒排索引是spider和build_index系统提前建立好的数据结构,为什么要使用这两种数据结构,是因为它能够快速的实现“用户网页检索”需求。
画外音,业务需求决定架构实现,查询起来都很快。
边栏推荐
- The visual experience has been comprehensively upgraded, and Howell group and Intel Evo 3.0 have jointly accelerated the reform of the PC industry
- list集合根据对象某属性求和,最大值等
- 单商户 V4.4,初心未变,实力依旧!
- Find the root of the following equation by chord cutting method, f (x) =x^3-5x^2+16x-80=0
- [vulnerability warning] cve-2022-26134 conflict Remote Code Execution Vulnerability POC verification and repair process
- CISP-PTE之PHP伪协议总结
- Parameter type setting error during batch update in project SQL
- 写单元测试的时候犯的错
- This article takes you through the addition, deletion, modification and query of JS processing tree structure data
- 数据湖(十四):Spark与Iceberg整合查询操作
猜你喜欢
How difficult is it to pass the certification of Intel Evo 3.0? Yilian technology tells you
Seaborn draws 11 histograms
vlunhub- BoredHackerBlog Moriarty Corp
2020-2022两周年创作纪念日
Explain in detail the functions and underlying implementation logic of the groups sets statement in SQL
Data Lake (XIV): spark and iceberg integrated query operation
Use of RLOCK lock
Convert obj set to entity set
Flet教程之 09 NavigationRail 基础入门(教程含源码)
通过的英特尔Evo 3.0整机认证到底有多难?忆联科技告诉你
随机推荐
ES6深入—ES6 Generator 函数
Today's sleep quality record 79 points
Cartoon: what is blue-green deployment?
Transaction rollback exception
一些認知的思考
通过的英特尔Evo 3.0整机认证到底有多难?忆联科技告诉你
CISP-PTE之PHP伪协议总结
《MongoDB入门教程》第04篇 MongoDB客户端
Cartoon: what is the eight queens problem?
Migrate /home partition
对象和类的关系
List uses stream flow to add according to the number of certain attributes of the element
视觉体验全面升级,豪威集团与英特尔Evo 3.0共同加速PC产业变革
Arduino controls a tiny hexapod 3D printing robot
研发效能度量指标构成及效能度量方法论
漫画:什么是分布式事务?
Research and practice of super-resolution technology in the field of real-time audio and video
抽象类中子类与父类
Parameter type setting error during batch update in project SQL
sql中set标签的使用