倒排索引
倒排索引(英语:Inverted index),也常被称为反向索引、置入档案或反向档案,是一种索引方法,被用来存储在全文搜索下某个单词在一个文档或者一组文档中的存储位置的映射。它是文档检索系统中最常用的数据结构。
有两种不同的反向索引形式:
后者的形式提供了更多的兼容性(比如短语搜索),但是需要更多的时间和空间来创建。
例子
以英文为例,下面是要被索引的文本:
0. "it is what it is"1. "what is it"2. "it is a banana"
我们就能得到下面的反向文件索引:
"a": {2}
"banana": {2}
"is": {0, 1, 2}
"it": {0, 1, 2}
"what": {0, 1}
检索的条件"what", "is" 和 "it" 将对应这个集合:。
对相同的文字,我们得到后面这些完全反向索引,由文档数量和当前查询的单词结果组成的的成对数据。
同样,文档数量和当前查询的单词结果都从零开始。所以,"banana": {(2, 3)} 就是说 "banana"在第三个文档里 (),而且在第三个文档的位置是第四个单词(地址为 3)。
"a": {(2, 2)}
"banana": {(2, 3)}
"is": {(0, 1), (0, 4), (1, 1), (2, 1)}
"it": {(0, 0), (0, 3), (1, 2), (2, 0)}
"what": {(0, 2), (1, 0)}
如果我们执行短语搜索"what is it" 我们得到这个短语的全部单词各自的结果所在文档为文档0和文档1。但是这个短语检索的连续的条件仅仅在文档1得到。
应用
参考书目
- Ribeiro, Berthier de Araújo Neto; Baeza-Yates, R. . Reading, Mass: Addison-Wesley Longman. 1999: 192. ISBN 0-201-39829-X.
- 高德纳,《计算机程序设计艺术》, Volume 3: "排序与索引"排序与索引Sorting and Searching, Third Edition. Addison-Wesley, 1997. ISBN 978-0-201-89685-5. Pages 560–563 of section 6.5: Retrieval on Secondary Keys.
- 贾斯廷·佐贝《文本索引的反向档案与签名档案比较》Justin Zobel, Alistair Moffat and Kotagiri Ramamohanarao, Inverted files versus signature files for text indexing. ACM Transactions on Database Systems (TODS), Volume 23, Issue 4 (December 1998), Pages: 453 - 490.
相关
This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.