> For the complete documentation index, see [llms.txt](https://wtifs.gitbook.io/diva-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wtifs.gitbook.io/diva-notes/db/dao-pai-suo-yin.md).

# 倒排索引

倒排索引（Inverted Index）是一种常用的文本索引技术，常用于搜索引擎中。它将文档中的每个词语的出现位置进行记录，并按照词语建立索引，将词语指向文档，从而方便快速地查询包含该词语的文档。倒排索引的名称来源于索引中单词与文档的位置关系被“倒过来”了。

举个例子，有123三个文档，其中1、3文档中包含 "alice bob" 两个词，那么就可以为此生成两个倒排索引，一个 `key` 是 alice，另一个 `key` 是 bob ，`value` 都是 1、3

如果用户输入查询单词 "alice"，只需要查询倒排索引中包含 "alice" 的文档编号，就可以很快地找到相关文档。倒排索引可以大大提高文本检索的效率和准确性。

再举个例子，有123三个用户，用户1是北京的，用户2也是北京的，用户3是深圳的，就可以建立 "北京" 和 "深圳" 两个倒排索引


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wtifs.gitbook.io/diva-notes/db/dao-pai-suo-yin.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
