当前位置:网站首页>搜索 正排索引 和 倒排索引 区别
搜索 正排索引 和 倒排索引 区别
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系统提前建立好的数据结构,为什么要使用这两种数据结构,是因为它能够快速的实现“用户网页检索”需求。
画外音,业务需求决定架构实现,查询起来都很快。
边栏推荐
- Defining strict standards, Intel Evo 3.0 is accelerating the upgrading of the PC industry
- 公司自用的国产API管理神器
- 今日睡眠质量记录79分
- Solve the Hanoi Tower problem [modified version]
- Modify PyUnit_ Time makes it support the time text of 'xx~xx months'
- 详解SQL中Groupings Sets 语句的功能和底层实现逻辑
- 助力数字经济发展,夯实数字人才底座—数字人才大赛在昆成功举办
- 记一次'非常诡异'的云安全组规则问题排查过程
- Flet教程之 12 Stack 重叠组建图文混合 基础入门(教程含源码)
- How difficult is it to pass the certification of Intel Evo 3.0? Yilian technology tells you
猜你喜欢

Coding devsecops helps financial enterprises run out of digital acceleration

Research and development efficiency measurement index composition and efficiency measurement methodology

abstract关键字和哪些关键字会发生冲突呢

数据湖(十四):Spark与Iceberg整合查询操作

今日睡眠质量记录79分

Data Lake (XIV): spark and iceberg integrated query operation

ES6深入—ES6 Class 类

List de duplication and count the number

Seaborn绘制11个柱状图

Defining strict standards, Intel Evo 3.0 is accelerating the upgrading of the PC industry
随机推荐
vulnhub-FirstBlood
漫画:什么是MapReduce?
This article takes you through the addition, deletion, modification and query of JS processing tree structure data
Cartoon: what is MapReduce?
ES6 drill down - ES6 generator function
CISP-PTE之PHP伪协议总结
The OBD deployment mode of oceanbase Community Edition is installed locally
list使用Stream流进行根据元素某属性数量相加
[Netease Yunxin] research and practice of super-resolution technology in the field of real-time audio and video
vant popup+其他组件的组合使用,及避坑指南
写单元测试的时候犯的错
Research and practice of super-resolution technology in the field of real-time audio and video
Background system sending verification code function
Modify PyUnit_ Time makes it support the time text of 'xx~xx months'
Codasip adds verify safe startup function to risc-v processor series
迁移/home分区
Boost the development of digital economy and consolidate the base of digital talents - the digital talent competition was successfully held in Kunming
详解SQL中Groupings Sets 语句的功能和底层实现逻辑
《21天精通TypeScript-3》-安装搭建TypeScript开发环境.md
阿掌的怀念