文本搜索解析器
本主题描述了Greenplum数据库文本搜索解析器从原始文本生成的token类型。
文本搜索解析器负责将原始文档文本拆分为token并标识每个token的类型,其中可能的类型集由解析器本身定义。 请注意,解析器根本不会修改文本 - 它只是识别合理的单词边界。 由于范围有限,因此与自定义词典相比,对特定于应用程序的自定义解析器的需求较少。 目前,Greenplum数据库只提供了一个内置解析器,它已被发现可用于各种应用程序。
内置解析器名为pg_catalog.default
。
它识别23种token类型,如下表所示。
Table 1. 默认解析器的token类型
Note:
解析器的“字母”概念由数据库的语言环境设置决定,特别是lc_ctype
。
仅包含基本ASCII字母的单词将作为单独的token类型报告,因为区分它们有时很有用。
在大多数欧洲语言中,token类型word
和asciiword
应该被视为相似。
电子邮件不支持RFC 5322定义的所有有效电子邮件字符。 具体而言,电子邮件用户名支持的唯一非字母数字字符是句号,短划线和下划线。
解析器可以从同一段文本生成重叠token。 例如,一个带连字符的单词将作为整个单词和每个组件报告:
SELECT alias, description, token FROM ts_debug('foo-bar-beta1');
alias | description | token
-----------------+------------------------------------------+---------------
numhword | Hyphenated word, letters and digits | foo-bar-beta1
hword_asciipart | Hyphenated word part, all ASCII | foo
blank | Space symbols | -
hword_asciipart | Hyphenated word part, all ASCII | bar
blank | Space symbols | -
hword_numpart | Hyphenated word part, letters and digits | beta1
这种行为是可取的,因为它允许搜索适用于整个复合词和组件。 这是另一个有指导性的例子:
SELECT alias, description, token FROM ts_debug('http://example.com/stuff/index.html');
alias | description | token
----------+---------------+------------------------------
protocol | Protocol head | http://
url | URL | example.com/stuff/index.html
host | Host | example.com
url_path | URL path | /stuff/index.html
Parent topic: 使用全文搜索