当前位置:网站首页>搜索 正排索引 和 倒排索引 区别
搜索 正排索引 和 倒排索引 区别
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系统提前建立好的数据结构,为什么要使用这两种数据结构,是因为它能够快速的实现“用户网页检索”需求。
画外音,业务需求决定架构实现,查询起来都很快。
边栏推荐
- Exception com alibaba. fastjson. JSONException: not match : - =
- 漫画:什么是分布式事务?
- Intel 13th generation Raptor Lake processor information exposure: more cores, larger cache
- Mongodb getting started Tutorial Part 04 mongodb client
- list去重并统计个数
- Cartoon: what is distributed transaction?
- Boost the development of digital economy and consolidate the base of digital talents - the digital talent competition was successfully held in Kunming
- 【深度学习】深度学习如何影响运筹学?
- Transaction rollback exception
- Codasip adds verify safe startup function to risc-v processor series
猜你喜欢

抽象类中子类与父类

【学术相关】多位博士毕业去了三四流高校,目前惨不忍睹……

Explain in detail the functions and underlying implementation logic of the groups sets statement in SQL

通过的英特尔Evo 3.0整机认证到底有多难?忆联科技告诉你
![21. [STM32] I don't understand the I2C protocol. Dig deep into the sequence diagram to help you write the underlying driver](/img/f4/2c935dd9933f5cd4324c29c41ab221.png)
21. [STM32] I don't understand the I2C protocol. Dig deep into the sequence diagram to help you write the underlying driver

Which keywords will conflict with the abstract keyword

Why should we learn mathematical modeling?

极坐标扇图使用场景与功能详解
英特尔第13代Raptor Lake处理器信息曝光:更多核心 更大缓存
![16.[STM32]从原理开始带你了解DS18B20温度传感器-四位数码管显示温度](/img/9f/c91904b6b1d3a1e85c0b50e43972e5.jpg)
16.[STM32]从原理开始带你了解DS18B20温度传感器-四位数码管显示温度
随机推荐
How can programmers improve their situation?
19.[STM32]HC_ SR04 ultrasonic ranging_ Timer mode (OLED display)
Apple 已弃用 NavigationView,使用 NavigationStack 和 NavigationSplitView 实现 SwiftUI 导航
一些認知的思考
效果编辑器新版上线!3D渲染、加标注、设置动画,这次一个编辑器就够了
list集合根据对象某属性求和,最大值等
16.[STM32]从原理开始带你了解DS18B20温度传感器-四位数码管显示温度
【学术相关】多位博士毕业去了三四流高校,目前惨不忍睹……
[graduation season] as a sophomore majoring in planning, I have something to say
OneForAll安装使用
今日睡眠质量记录79分
vulnhub-FirstBlood
极坐标扇图使用场景与功能详解
DataArts Studio数据架构——数据标准介绍
vant tabbar遮挡内容的解决方式
Transaction rollback exception
【深度学习】深度学习如何影响运筹学?
后台系统发送验证码功能
Cheer yourself up
Record the pits encountered in the raspberry pie construction environment...