对于 AI 代理:可在 https://www.mongodb.com/zh-cn/docs/llms.txt 获取文档索引—通过在任何 URL 路径后添加 .md 可获取所有页面的 Markdown 版本。
Docs 菜单

简单分析器

只要 simple 分析器找到非字母字符(例如空格、标点符号或者一个或多个数字),它就会将文本划分为可搜索术语(词元)。它将所有文本转换为小写。

如果您选择 Refine Your Index, Atlas用户界面会在 Index Configurations 部分中显示标题为 View text analysis of your selected index configuration 的部分。如果展开此部分, Atlas用户界面会显示 simple分析器为每个示例字符串生成的索引和搜索词元。 当您在Atlas用户界面Visual Editor 中创建或编辑索引时,您可以看到 simple分析器为内置示例文档和查询字符串创建的词元。

重要

MongoDB Search 不会对分析器词元大小超过 32766 字节的字符串字段索引。 如果使用关键字分析器,则不会对超过 32766 字节的字符串字段编制索引。

以下示例索引定义使用 simple 分析器指定 sample_mflix.movies 集合中 title 字段上的索引。要跟随此示例,请在集群上加载示例数据,并使用mongosh或按照创建 MongoDB Search 索引教程中的步骤导航到 Atlas UI 中的 Create a Search Index 页面。

然后,使用 movies 集合作为数据源,按照示例过程从 mongosh 或 Atlas 用户界面 Visual EditorJSON editor 创建索引。


以下查询在title字段中搜索词语lion ,并将输出限制为五个结果。

MongoDB Search 通过使用 lucene.simple分析器对 title字段中的文本执行以下操作来返回这些文档:

  • 将文本转换为小写。

  • 通过在存在非字母字符的位置分割文本来创建单独的词元。

下表显示 MongoDB Search 使用 简单分析器 为结果中的每个文档创建的标记。为了进行比较,该表还显示来自 标准分析器空白分析器:的标记

标题
简单分析器词元
标准分析器词元
空白分析器令牌

White Lion

white, lion

white, lion

White, Lion

The Lion King

the, lion , king

the, lion , king

The, Lion , King

The Lion King 1 1/2

the, lion , king

the, lion , king , 1 , 1 , 2

The, Lion , King , 1 , 1/2

Lion's Den

lion, s , den

lion's, den

Lion's, Den

MongoDB Search 在结果中返回文档 Lion's Den,因为 simple 分析器为 lion 创建了单独的词元,该词元与查询术语 lion 匹配。相反,如果使用 Standard AnalyzerWhitespace Analyzer 对字段进行索引,MongoDB Search 将不会返回 Lion's Den。The Standard 分析器 would create the token lion's and the Whitespace 分析器 would create Lion's, but neither would create a token for lion.