Overview
Atlas Search 分析器通过对字符序列执行一系列转换、筛选和分组操作来准备要编制索引的文档集。可以从 Atlas UI 定义自定义分析器来满足特定索引编制需求。
自定义Atlas Search分析器由 分词器、可选的字符筛选器列表和可选的词元筛选器列表组成。当Atlas Search使用自定义分析器分析文本时,文本首先通过字符筛选器,然后是分词器,最后是词元筛选器。
语法
自定义分析器采用以下语法:
"analyzers": [ { "name": "<name>", "charFilters": [ <list-of-character-filters> ], "tokenizer": { "type": "<tokenizer-type>" }, "tokenFilters": [ <list-of-token-filters> ] } ]
属性
自定义分析器具有以下属性:
属性 | 类型 | 说明 | 必需? |
---|---|---|---|
| 字符串 | 自定义分析器的名称。名称在索引中必须唯一,并且不能以下列任何字符串开头:
| 是 |
| 对象列表 | no | |
| 对象 | 是 | |
| 对象列表 | 包含零个或多个词元筛选器的数组。 词元筛选器执行以下操作:
若要了解更多信息,请参见词元过滤器。 | no |
内置自定义分析器模板
Atlas UI Visual Editor 提供了在以下常用模板之间进行选择的选项,以帮助您开始构建自定义分析器:
电子邮件解析器 — 使用此工具可通过 uaxUrlEmail 分词器对最多 200 个字符的电子邮件地址进行分词。例如,您可以将此分析器应用于
page_updated_by.email
字段中的示例集合。电话号码 — 使用 regexCaptureGroup 分词器从美国格式的电话号码中创建单个词元。例如,您可以将此分析器应用于示例集合中的
page_updated_by.phone
字段。破折号分隔的 ID——使用此功能可使用 regexSplit 分词器从连字符分隔的文本中创建标记。例如,您可以将此分析器应用于示例集合中的
message
字段。
可以使用这些内置的自定义分析器,也可以使用 Atlas Search Visual Editor 或 JSON 编辑器创建自己的自定义分析器。
示例集合
字符筛选器、分词器和令牌筛选器页面包含相应的示例索引定义和查询示例。这些示例使用包含以下文档的示例 minutes
集合:
{ "_id": 1, "page_updated_by": { "last_name": "AUERBACH", "first_name": "Siân", "email": "auerbach@example.com", "phone": "(123)-456-7890" }, "title": "The team's weekly meeting", "message": "try to siGn-In", "text": { "en_US": "<head> This page deals with department meetings.</head>", "sv_FI": "Den här sidan behandlar avdelningsmöten", "fr_CA": "Cette page traite des réunions de département" } }
{ "_id": 2, "page_updated_by": { "last_name": "OHRBACH", "first_name": "Noël", "email": "ohrbach@example.com", "phone": "(123) 456 0987" }, "title": "The check-in with sales team", "message": "do not forget to SIGN-IN. See ① for details.", "text" : { "en_US": "The head of the sales department spoke first.", "fa_IR": "ابتدا رئیس بخش فروش صحبت کرد", "sv_FI": "Först talade chefen för försäljningsavdelningen" } }
{ "_id": 3, "page_updated_by": { "last_name": "LEWINSKY", "first_name": "Brièle", "email": "lewinsky@example.com", "phone": "(123).456.9870" }, "title": "The regular board meeting", "message": "try to sign-in", "text" : { "en_US": "<body>We'll head out to the conference room by noon.</body>" } }
{ "_id": 4, "page_updated_by": { "last_name": "LEVINSKI", "first_name": "François", "email": "levinski@example.com", "phone": "123-456-8907" }, "title": "The daily huddle on tHe StandUpApp2", "message": "write down your signature or phone №", "text" : { "en_US": "<body>This page has been updated with the items on the agenda.</body>" , "es_MX": "La página ha sido actualizada con los puntos de la agenda.", "pl_PL": "Strona została zaktualizowana o punkty porządku obrad." } }
了解详情
要了解有关创建自己的自定义分析器的更多信息,请参阅以下参考页面: