词形变化在通过 charset_table 规则对输入文本进行分词后应用。它们本质上允许你用另一个词替换一个词。通常,这用于将不同的词形归一化为单一的标准形式(例如,将所有变体如 "walks"、"walked"、"walking" 规范化为标准形式 "walk")。它也可以用来实现 词干提取 的例外情况,因为词干提取不会应用于词形变化列表中的词。
wordforms = path/to/wordforms.txt
wordforms = path/to/alternateforms.txt
wordforms = path/to/dict*.txt
词形变化字典。可选,默认为空。
词形变化字典用于在索引和搜索过程中规范化输入词。因此,对于 plain table 来说,必须旋转表以应用词形变化文件中的更改。
CREATE TABLE products(title text, price float) wordforms = '/var/lib/manticore/wordforms.txt' wordforms = '/var/lib/manticore/alternateforms.txt /var/lib/manticore/dict*.txt'
POST /cli -d "
CREATE TABLE products(title text, price float) wordforms = '/var/lib/manticore/wordforms.txt' wordforms = '/var/lib/manticore/alternateforms.txt' wordforms = '/var/lib/manticore/dict*.txt'"
$index = new \Manticoresearch\Index($client);
$index->setName('products');
$index->create([
'title'=>['type'=>'text'],
'price'=>['type'=>'float']
],[
'wordforms' => [
'/var/lib/manticore/wordforms.txt',
'/var/lib/manticore/alternateforms.txt',
'/var/lib/manticore/dict*.txt'
]
]);
utilsApi.sql('CREATE TABLE products(title text, price float) wordforms = \'/var/lib/manticore/wordforms.txt\' wordforms = \'/var/lib/manticore/alternateforms.txt\' wordforms = \'/var/lib/manticore/dict*.txt\'')
await utilsApi.sql('CREATE TABLE products(title text, price float) wordforms = \'/var/lib/manticore/wordforms.txt\' wordforms = \'/var/lib/manticore/alternateforms.txt\' wordforms = \'/var/lib/manticore/dict*.txt\'')
res = await utilsApi.sql('CREATE TABLE products(title text, price float)wordforms = \'/var/lib/manticore/wordforms.txt\' wordforms = \'/var/lib/manticore/alternateforms.txt\' wordforms = \'/var/lib/manticore/dict*.txt\'');
utilsApi.sql("CREATE TABLE products(title text, price float) wordforms = '/var/lib/manticore/wordforms.txt' wordforms = '/var/lib/manticore/alternateforms.txt' wordforms = '/var/lib/manticore/dict*.txt'", true);
utilsApi.Sql("CREATE TABLE products(title text, price float) wordforms = '/var/lib/manticore/wordforms.txt' wordforms = '/var/lib/manticore/alternateforms.txt' wordforms = '/var/lib/manticore/dict*.txt'", true);
utils_api.sql("CREATE TABLE products(title text, price float) wordforms = '/var/lib/manticore/wordforms.txt' wordforms = '/var/lib/manticore/alternateforms.txt' wordforms = '/var/lib/manticore/dict*.txt'", Some(true)).await;
table products {
wordforms = /var/lib/manticore/wordforms.txt
wordforms = /var/lib/manticore/alternateforms.txt
wordforms = /var/lib/manticore/dict*.txt
type = rt
path = tbl
rt_field = title
rt_attr_uint = price
}
Manticore 中的词形变化支持设计为能够良好处理大型字典。它们对索引速度有适度影响;例如,包含 100 万条目的字典会使全文索引速度降低约 1.5 倍。搜索速度完全不受影响。额外的内存占用大致等于字典文件大小,且字典在多个表之间共享。例如,如果同一个 50 MB 的词形变化文件被指定给 10 个不同的表,额外的 searchd 内存使用大约为 50 MB。
字典文件应为简单的纯文本格式。每行应包含源词形和目标词形,使用 UTF-8 编码,并以“大于号”分隔。加载文件时会应用 charset_table 中的规则。因此,如果你不修改 charset_table,你的词形变化将是不区分大小写的,类似于其他全文索引的数据。以下是文件内容的示例:
walks > walk
walked > walk
walking > walk
有一个捆绑的工具叫做 Spelldump,它可以帮助你创建 Manticore 可读取格式的字典文件。该工具可以读取以 ispell 或 MySpell 格式的源 .dict 和 .aff 字典文件,这些文件随 OpenOffice 一起捆绑提供。
你可以将多个源词映射到一个目标词。该过程作用于分词后的词元,而非源文本,因此空白和标记的差异会被忽略。
你可以使用 => 符号代替 >。也允许注释(以 # 开头)。最后,如果一行以波浪号(~)开头,词形变化将在形态学处理之后应用,而非之前(注意此情况下只支持单个源词和目标词)。
core 2 duo > c2d
e6600 > c2d
core 2duo => c2d # Some people write '2duo' together...
~run > walk # Along with stem_en morphology enabled replaces 'run', 'running', 'runs' (and any other words that stem to just 'run') to 'walk'
如果你需要将 >、= 或 ~ 作为普通字符使用,可以通过在它们前面加反斜杠(\)来转义。> 和 = 都应以此方式转义。示例如下:
a\> > abc
\>b > bcd
c\=\> => cde
\=\>d => def
\=\>a \> f \> => foo
\~g => bar
s02e02 > season 2 episode 2
s3 e3 > season 3 episode 3
你可以指定多个文件,而不仅仅是一个。可以使用通配符作为模式,所有匹配的文件将按简单升序处理:
在 RT 模式下,只允许使用绝对路径。
如果使用多字节编码页且文件名包含非拉丁字符,结果顺序可能不完全是字母顺序。如果在多个文件中发现相同的词形变化定义,后面的定义将覆盖之前的。
create table tbl1 ... wordforms='/tmp/wf*'
create table tbl2 ... wordforms='/tmp/wf, /tmp/wf2'
wordforms=/tmp/wf
wordforms=/tmp/wf2
wordforms=/tmp/wf_new*
Last modified: August 28, 2025
异常(也称为同义词)允许将一个或多个标记(包括通常会被排除的字符的标记)映射到单个关键词。它们类似于wordforms,因为它们也执行映射,但有一些重要的区别。
与wordforms的区别简要总结如下:
exceptions = path/to/exceptions.txt
分词异常文件。可选,默认为空。
在RT模式下,只允许使用绝对路径。
预期的文件格式是纯文本,每行一个异常。行格式如下:
map-from-tokens => map-to-token
示例文件:
at & t => at&t
AT&T => AT&T
Standarten Fuehrer => standartenfuhrer
Standarten Fuhrer => standartenfuhrer
MS Windows => ms windows
Microsoft Windows => ms windows
C++ => cplusplus
c++ => cplusplus
C plus plus => cplusplus
\=\>abc\> => abc
这里的所有标记都是区分大小写的,并且不会被charset_table规则处理。因此,以上示例异常文件中,at&t文本将被分词为两个关键词at和t,因为小写字母的原因。另一方面,AT&T将完全匹配并生成单个AT&T关键词。
如果需要将>或=作为普通字符使用,可以通过在它们前面加反斜杠(\)来转义。>和=都应以这种方式转义。
请注意,映射到的关键词:
在上述示例中,ms windows查询将不会匹配包含MS Windows文本的文档。该查询将被解释为两个关键词ms和windows的查询。MS Windows的映射是单个关键词ms windows,中间有空格。另一方面,standartenfuhrer将检索包含Standarten Fuhrer或Standarten Fuehrer内容(大小写完全如示例所示),或关键词本身的任何大小写变体的文档,例如staNdarTenfUhreR。(但它不会匹配standarten fuhrer:该文本由于大小写敏感性不匹配任何列出的异常,因此被索引为两个独立的关键词。)
映射来源标记列表中的空白符很重要,但其数量无关紧要。映射来源列表中的任意数量空白符都将匹配索引文档或查询中的任意数量空白符。例如,AT & T映射来源标记将匹配AT & T文本,无论映射来源部分和索引文本中的空格数量如何。因此,这样的文本将被索引为特殊的AT&T关键词,这得益于示例中的第一条目。
异常还允许捕获特殊字符(这些字符是一般charset_table规则的例外;因此得名)。假设你通常不想将+视为有效字符,但仍想能够搜索一些此规则的例外,如C++。上述示例完全满足此需求,完全独立于表中包含哪些字符。
使用plain table时,必须旋转表以合并异常文件的更改。对于实时表,更改只会应用于新文档。
CREATE TABLE products(title text, price float) exceptions = '/usr/local/manticore/data/exceptions.txt'
POST /cli -d "
CREATE TABLE products(title text, price float) exceptions = '/usr/local/manticore/data/exceptions.txt'"
$index = new \Manticoresearch\Index($client);
$index->setName('products');
$index->create([
'title'=>['type'=>'text'],
'price'=>['type'=>'float']
],[
'exceptions' => '/usr/local/manticore/data/exceptions.txt'
]);
utilsApi.sql('CREATE TABLE products(title text, price float) exceptions = \'/usr/local/manticore/data/exceptions.txt\'')
await utilsApi.sql('CREATE TABLE products(title text, price float) exceptions = \'/usr/local/manticore/data/exceptions.txt\'')
res = await utilsApi.sql('CREATE TABLE products(title text, price float) exceptions = \'/usr/local/manticore/data/exceptions.txt\'');
utilsApi.sql("CREATE TABLE products(title text, price float) exceptions = '/usr/local/manticore/data/exceptions.txt'", true);
utilsApi.Sql("CREATE TABLE products(title text, price float) exceptions = '/usr/local/manticore/data/exceptions.txt'", true);
utils_api.sql("CREATE TABLE products(title text, price float) exceptions = '/usr/local/manticore/data/exceptions.txt'", Some(true)).await;
table products {
exceptions = /usr/local/manticore/data/exceptions.txt
type = rt
path = tbl
rt_field = title
rt_attr_uint = price
}
Last modified: August 28, 2025
形态学预处理器可以在索引期间应用于单词,以规范同一单词的不同形式并改进分词。例如,英文词干提取器可以将 "dogs" 和 "dog" 规范为 "dog",从而使这两个关键词的搜索结果相同。
Manticore 有四种内置的形态学预处理器:
- 词形还原器:将单词还原为其词根或词元。例如,"running" 可以还原为 "run","octopi" 可以还原为 "octopus"。注意,有些单词可能有多个对应的词根形式。例如,"dove" 既可以是 "dive" 的过去式,也可以是表示鸟类的名词,如 "A white dove flew over the cuckoo's nest." 在这种情况下,词形还原器可以生成所有可能的词根形式。
- 词干提取器:通过移除或替换某些已知后缀,将单词还原为词干。得到的词干不一定是有效单词。例如,Porter 英文词干提取器将 "running" 还原为 "run",将 "business" 还原为 "busi"(不是有效单词),并且不会对 "octopi" 进行还原。
- 语音算法:用语音编码替换单词,即使单词不同但发音相近,编码也相同。
- 分词算法:将文本拆分成单词。目前仅支持中文。
morphology = morphology1[, morphology2, ...]
morphology 指令指定要应用于被索引单词的形态学预处理器列表。这是一个可选设置,默认不应用任何预处理器。
Manticore 内置了以下形态学预处理器:
- 英语、俄语和德语词形还原器
- 英语、俄语、阿拉伯语和捷克语词干提取器
- SoundEx 和 MetaPhone 语音算法
- 中文分词算法
- 还提供了 Snowball(libstemmer)词干提取器,支持超过 15 种其他语言。
词形还原器需要字典 .pak 文件,可以通过 manticore-language-packs 软件包安装,或从 Manticore 网站下载。在后者情况下,字典需要放置在由 lemmatizer_base 指定的目录中。
此外,lemmatizer_cache 设置可以通过使用更多内存缓存未压缩字典来加速词形还原。
中文分词可以使用 ICU 或 Jieba(需要 manticore-language-packs 包)。这两个库提供比 n-gram 更准确的分词,但速度稍慢。charset_table 必须包含所有中文字符,可以使用 cont、cjk 或 chinese 字符集来实现。当设置 morphology=icu_chinese 或 morphology=jieba_chinese 时,文档首先由 ICU 或 Jieba 预处理。然后,分词器根据 charset_table 处理结果,最后应用 morphology 选项中的其他形态学处理器。只有包含中文的文本部分会传递给 ICU/Jieba 进行分词,其他部分可以通过不同方式修改,如不同的形态学处理或 charset_table。
内置的英语和俄语词干提取器比 libstemmer 版本更快,但可能产生略有不同的结果。
Soundex 实现与 MySQL 一致。Metaphone 实现基于 Double Metaphone 算法,索引主编码。
要使用 morphology 选项,请指定一个或多个内置选项,包括:
- none:不执行任何形态学处理
- lemmatize_ru - 应用俄语词形还原器并选择单一词根形式
- lemmatize_uk - 应用乌克兰语词形还原器并选择单一词根形式(先在 Centos 或 Ubuntu/Debian 安装)。为确保词形还原器正常工作,请确保在
charset_table 中保留特定的乌克兰字符,因为默认不包含。可通过如下方式覆盖:charset_table='non_cont,U+0406->U+0456,U+0456,U+0407->U+0457,U+0457,U+0490->U+0491,U+0491'。这里 有一个关于如何安装和使用乌克兰词形还原器的交互式课程。
- lemmatize_en - 应用英语词形还原器并选择单一词根形式
- lemmatize_de - 应用德语词形还原器并选择单一词根形式
- lemmatize_ru_all - 应用俄语词形还原器并索引所有可能的词根形式
- lemmatize_uk_all - 应用乌克兰语词形还原器并索引所有可能的词根形式。安装链接见上,并注意
charset_table 设置。
- lemmatize_en_all - 应用英语词形还原器并索引所有可能的词根形式
- lemmatize_de_all - 应用德语词形还原器并索引所有可能的词根形式
- stem_en - 应用 Porter 英语词干提取器
- stem_ru - 应用 Porter 俄语词干提取器
- stem_enru - 同时应用 Porter 英语和俄语词干提取器
- stem_cz - 应用捷克语词干提取器
- stem_ar - 应用阿拉伯语词干提取器
- soundex - 用 SOUNDEX 代码替换关键词
- metaphone - 用 METAPHONE 代码替换关键词
- icu_chinese - 使用 ICU 进行中文分词
- jieba_chinese - 使用 Jieba 进行中文分词(需要
manticore-language-packs 包)
- libstemmer_* 。详情请参阅 支持语言列表
可以指定多个词干提取器,用逗号分隔。它们将按照列出的顺序应用于输入的单词,并且一旦其中一个词干提取器修改了单词,处理将停止。此外,当启用wordforms功能时,单词将首先在词形字典中查找。如果字典中有匹配的条目,则根本不会应用词干提取器。wordforms可用于实现词干提取的例外情况。
CREATE TABLE products(title text, price float) morphology = 'stem_en, libstemmer_sv'
POST /cli -d "CREATE TABLE products(title text, price float) morphology = 'stem_en, libstemmer_sv'"
$index = new \Manticoresearch\Index($client);
$index->setName('products');
$index->create([
'title'=>['type'=>'text'],
'price'=>['type'=>'float']
],[
'morphology' => 'stem_en, libstemmer_sv'
]);
utilsApi.sql('CREATE TABLE products(title text, price float) morphology = \'stem_en, libstemmer_sv\'')
await utilsApi.sql('CREATE TABLE products(title text, price float) morphology = \'stem_en, libstemmer_sv\'')
res = await utilsApi.sql('CREATE TABLE products(title text, price float) morphology = \'stem_en, libstemmer_sv\'');
utilsApi.sql("CREATE TABLE products(title text, price float) morphology = 'stem_en, libstemmer_sv'", true);
utilsApi.Sql("CREATE TABLE products(title text, price float) morphology = 'stem_en, libstemmer_sv'", true);
utils_api.sql("CREATE TABLE products(title text, price float) morphology = 'stem_en, libstemmer_sv'", Some(true)).await;
table products {
morphology = stem_en, libstemmer_sv
type = rt
path = tbl
rt_field = title
rt_attr_uint = price
}
morphology_skip_fields = field1[, field2, ...]
跳过形态学预处理的字段列表。可选,默认值为空(对所有字段应用预处理器)。
CREATE TABLE products(title text, name text, price float) morphology_skip_fields = 'name' morphology = 'stem_en'
POST /cli -d "
CREATE TABLE products(title text, name text, price float) morphology_skip_fields = 'name' morphology = 'stem_en'"
$index = new \Manticoresearch\Index($client);
$index->setName('products');
$index->create([
'title'=>['type'=>'text'],
'price'=>['type'=>'float']
],[
'morphology_skip_fields' => 'name',
'morphology' => 'stem_en'
]);
utilsApi.sql('CREATE TABLE products(title text, price float) morphology_skip_fields = \'name\' morphology = \'stem_en\'')
await utilsApi.sql('CREATE TABLE products(title text, price float) morphology_skip_fields = \'name\' morphology = \'stem_en\'')
res = await utilsApi.sql('CREATE TABLE products(title text, price float) morphology_skip_fields = \'name\' morphology = \'stem_en\'');
utilsApi.sql("CREATE TABLE products(title text, price float) morphology_skip_fields = 'name' morphology = 'stem_en'", true);
utilsApi.Sql("CREATE TABLE products(title text, price float) morphology_skip_fields = 'name' morphology = 'stem_en'", true);
utils_api.sql("CREATE TABLE products(title text, price float) morphology_skip_fields = 'name' morphology = 'stem_en'", Some(true)).await;
table products {
morphology_skip_fields = name
morphology = stem_en
type = rt
path = tbl
rt_field = title
rt_field = name
rt_attr_uint = price
}
min_stemming_len = length
启用词干提取的最小单词长度。可选,默认值为1(对所有单词进行词干提取)。
词干提取器并不完美,有时可能产生不理想的结果。例如,将“gps”关键词通过英语的Porter词干提取器处理,结果是“gp”,这并非真正的意图。min_stemming_len功能允许您根据源单词长度抑制词干提取,即避免对过短的单词进行词干提取。比给定阈值更短的关键词将不会被词干提取。注意,长度恰好等于指定值的关键词会被词干提取。因此,为了避免对3个字符的关键词进行词干提取,您应将值指定为4。有关更细粒度的控制,请参阅wordforms功能。
CREATE TABLE products(title text, price float) min_stemming_len = '4' morphology = 'stem_en'
POST /cli -d "
CREATE TABLE products(title text, price float) min_stemming_len = '4' morphology = 'stem_en'"
$index = new \Manticoresearch\Index($client);
$index->setName('products');
$index->create([
'title'=>['type'=>'text'],
'price'=>['type'=>'float']
],[
'min_stemming_len' => '4',
'morphology' => 'stem_en'
]);
utilsApi.sql('CREATE TABLE products(title text, price float) min_stemming_len = \'4\' morphology = \'stem_en\'')
await utilsApi.sql('CREATE TABLE products(title text, price float) min_stemming_len = \'4\' morphology = \'stem_en\'')
res = await utilsApi.sql('CREATE TABLE products(title text, price float) min_stemming_len = \'4\' morphology = \'stem_en\'');
utilsApi.sql("CREATE TABLE products(title text, price float) min_stemming_len = '4' morphology = 'stem_en'", true);
utilsApi.Sql("CREATE TABLE products(title text, price float) min_stemming_len = '4' morphology = 'stem_en'", true);
utils_api.sql("CREATE TABLE products(title text, price float) min_stemming_len = '4' morphology = 'stem_en'", Some(true)).await;
table products {
min_stemming_len = 4
morphology = stem_en
type = rt
path = tbl
rt_field = title
rt_attr_uint = price
}
index_exact_words = {0|1}
此选项允许对原始关键词及其形态学修改版本进行索引。但是,被wordforms和exceptions重新映射的原始关键词无法被索引。默认值为0,表示默认情况下此功能被禁用。
这允许在查询语言中使用精确形式操作符。启用此功能将增加全文索引的大小和索引时间,但不会影响搜索性能。
CREATE TABLE products(title text, price float) index_exact_words = '1' morphology = 'stem_en'
POST /cli -d "
CREATE TABLE products(title text, price float) index_exact_words = '1' morphology = 'stem_en'"
$index = new \Manticoresearch\Index($client);
$index->setName('products');
$index->create([
'title'=>['type'=>'text'],
'price'=>['type'=>'float']
],[
'index_exact_words' => '1',
'morphology' => 'stem_en'
]);
utilsApi.sql('CREATE TABLE products(title text, price float) index_exact_words = \'1\' morphology = \'stem_en\'')
await utilsApi.sql('CREATE TABLE products(title text, price float) index_exact_words = \'1\' morphology = \'stem_en\'')
res = await utilsApi.sql('CREATE TABLE products(title text, price float) index_exact_words = \'1\' morphology = \'stem_en\'');
utilsApi.sql("CREATE TABLE products(title text, price float) index_exact_words = '1' morphology = 'stem_en'", true);
utilsApi.Sql("CREATE TABLE products(title text, price float) index_exact_words = '1' morphology = 'stem_en'", true);
utils_api.sql("CREATE TABLE products(title text, price float) index_exact_words = '1' morphology = 'stem_en'", Some(true)).await;
table products {
index_exact_words = 1
morphology = stem_en
type = rt
path = tbl
rt_field = title
rt_attr_uint = price
}
jieba_hmm = {0|1}
启用或禁用Jieba分词工具中的HMM。可选,默认值为1。
在Jieba中,HMM(隐马尔可夫模型)选项指的是一种用于分词的算法。具体来说,它允许Jieba通过识别未知词,尤其是词典中不存在的词,来执行中文分词。
Jieba主要使用基于词典的方法来分割已知词,但当启用HMM选项时,它会应用统计模型来识别词典中不存在的词或短语的可能词边界。这对于分割新词、罕见词、姓名和俚语特别有用。
总之,jieba_hmm选项有助于提高分词准确性,但会牺牲索引性能。它必须与morphology = jieba_chinese一起使用,详见中文、日文和韩文(CJK)及泰语。
CREATE TABLE products(title text, price float) morphology = 'jieba_chinese' jieba_hmm = '0'
POST /cli -d "
CREATE TABLE products(title text, price float) morphology = 'jieba_chinese' jieba_hmm = '0'"
$index = new \Manticoresearch\Index($client);
$index->setName('products');
$index->create([
'title'=>['type'=>'text'],
'price'=>['type'=>'float']
],[
'morphology' => 'jieba_chinese',
'jieba_hmm'='1'
]);
utilsApi.sql('CREATE TABLE products(title text, price float) morphology = \'jieba_chinese\' jieba_hmm = \'0\'')
await utilsApi.sql('CREATE TABLE products(title text, price float) morphology = \'jieba_chinese\' jieba_hmm = \'0\'')
res = await utilsApi.sql('CREATE TABLE products(title text, price float) morphology = \'jieba_chinese\' jieba_hmm = \'0\'');
utilsApi.sql("CREATE TABLE products(title text, price float) morphology = 'jieba_chinese' jieba_hmm = '0'", true);
utilsApi.Sql("CREATE TABLE products(title text, price float) morphology = 'jieba_chinese' jieba_hmm = '0'", true);
utils_api.sql("CREATE TABLE products(title text, price float) morphology = 'jieba_chinese' jieba_hmm = '0'", Some(true)).await;
table products {
morphology = jieba_chinese
jieba_hmm = 0
type = rt
path = tbl
rt_field = title
rt_attr_uint = price
}
jieba_mode = {accurate|full|search}
Jieba segmentation mode. Optional; the default is accurate.
In accurate mode, Jieba splits the sentence into the most precise words using dictionary matching. This mode focuses on precision, ensuring that the segmentation is as accurate as possible.
In full mode, Jieba tries to split the sentence into every possible word combination, aiming to include all potential words. This mode focuses on maximizing recall, meaning it identifies as many words as possible, even if some of them overlap or are less commonly used. It returns all the words found in its dictionary.
In search mode, Jieba breaks the text into both whole words and smaller parts, combining precise segmentation with extra detail by providing overlapping word fragments. This mode balances precision and recall, making it useful for search engines.
jieba_mode should be used with morphology = jieba_chinese. See Chinese, Japanese, Korean (CJK) and Thai languages.
CREATE TABLE products(title text, price float) morphology = 'jieba_chinese' jieba_mode = 'full'
POST /cli -d "
CREATE TABLE products(title text, price float) morphology = 'jieba_chinese' jieba_mode = 'full'"
$index = new \Manticoresearch\Index($client);
$index->setName('products');
$index->create([
'title'=>['type'=>'text'],
'price'=>['type'=>'float']
],[
'morphology' => 'jieba_chinese',
'jieba_mode'='full'
]);
utilsApi.sql('CREATE TABLE products(title text, price float) morphology = \'jieba_chinese\' jieba_mode = \'full\'')
await utilsApi.sql('CREATE TABLE products(title text, price float) morphology = \'jieba_chinese\' jieba_mode = \'full\'')
res = await utilsApi.sql('CREATE TABLE products(title text, price float) morphology = \'jieba_chinese\' jieba_mode = \'full\'');
utilsApi.sql("CREATE TABLE products(title text, price float) morphology = 'jieba_chinese' jieba_mode = 'full'", true);
utilsApi.Sql("CREATE TABLE products(title text, price float) morphology = 'jieba_chinese' jieba_mode = 'full'", true);
utils_api.sql("CREATE TABLE products(title text, price float) morphology = 'jieba_chinese' jieba_mode = 'full'", Some(true)).await;
table products {
morphology = jieba_chinese
jieba_mode = full
type = rt
path = tbl
rt_field = title
rt_attr_uint = price
}
jieba_user_dict_path = path/to/stopwords/file
Path to the Jieba user dictionary. Optional.
Jieba, a Chinese text segmentation library, uses dictionary files to assist with word segmentation. The format of these dictionary files is as follows: each line contains a word, split into three parts separated by spaces — the word itself, word frequency, and part of speech (POS) tag. The word frequency and POS tag are optional and can be omitted. The dictionary file must be UTF-8 encoded.
Example:
创新办 3 i
云计算 5
凱特琳 nz
台中
jieba_user_dict_path should be used with morphology = jieba_chinese. For more details, see Chinese, Japanese, Korean (CJK), and Thai languages.
CREATE TABLE products(title text, price float) morphology = 'jieba_chinese' jieba_user_dict_path = '/usr/local/manticore/data/user-dict.txt'
POST /cli -d "
CREATE TABLE products(title text, price float) morphology = 'jieba_chinese' jieba_user_dict_path = '/usr/local/manticore/data/user-dict.txt'"
$index = new \Manticoresearch\Index($client);
$index->setName('products');
$index->create([
'title'=>['type'=>'text'],
'price'=>['type'=>'float']
],[
'morphology' => 'jieba_chinese',
'jieba_user_dict_path' = '/usr/local/manticore/data/user-dict.txt'
]);
utilsApi.sql('CREATE TABLE products(title text, price float) morphology = \'jieba_chinese\' jieba_user_dict_path = \'/usr/local/manticore/data/user-dict.txt\'')
await utilsApi.sql('CREATE TABLE products(title text, price float) morphology = \'jieba_chinese\' jieba_user_dict_path = \'/usr/local/manticore/data/user-dict.txt\'')
res = await utilsApi.sql('CREATE TABLE products(title text, price float) morphology = \'jieba_chinese\' jieba_user_dict_path = \'/usr/local/manticore/data/user-dict.txt\'');
utilsApi.sql("CREATE TABLE products(title text, price float) morphology = 'jieba_chinese' jieba_user_dict_path = '/usr/local/manticore/data/user-dict.txt'", true);
utilsApi.Sql("CREATE TABLE products(title text, price float) morphology = 'jieba_chinese' jieba_user_dict_path = '/usr/local/manticore/data/user-dict.txt'", true);
utils_api.sql("CREATE TABLE products(title text, price float) morphology = 'jieba_chinese' jieba_user_dict_path = '/usr/local/manticore/data/user-dict.txt'", Some(true)).await;
table products {
morphology = jieba_chinese
jieba_user_dict_path = /usr/local/manticore/data/user-dict.txt
type = rt
path = tbl
rt_field = title
rt_attr_uint = price
}
Last modified: August 28, 2025
html_strip = {0|1}
此选项决定是否应从传入的全文数据中去除 HTML 标记。默认值为 0,表示禁用去除。要启用去除,请将值设置为 1。
HTML 标签和实体被视为标记并将被处理。
HTML 标签会被移除,而它们之间的内容(例如 <p> 和 </p> 之间的所有内容)则保持不变。您可以选择保留并索引标签属性(例如 A 标签中的 HREF 属性或 IMG 标签中的 ALT 属性)。一些知名的内联标签,如 A、B、I、S、U、BASEFONT、BIG、EM、FONT、IMG、LABEL、SMALL、SPAN、STRIKE、STRONG、SUB、SUP 和 TT,会被完全移除。所有其他标签被视为块级标签,并被替换为空白。例如,文本 te<b>st</b> 会被索引为单个关键词 'test',而 te<p>st</p> 会被索引为两个关键词 'te' 和 'st'。
HTML 实体会被解码并替换为对应的 UTF-8 字符。去除器支持数字形式的实体(例如 ï)和文本形式的实体(例如 ó 或 ),并支持 HTML4 标准指定的所有实体。
该去除器设计用于处理格式正确的 HTML 和 XHTML,但在处理格式错误的输入(如带有多余的 < 或未闭合的 > 的 HTML)时可能产生意外结果。
请注意,只有标签本身以及 HTML 注释会被去除。要去除标签内容,包括嵌入的脚本,请参见 html_remove_elements 选项。标签名称没有限制,意味着所有看起来像有效标签开始、结束或注释的内容都会被去除。
CREATE TABLE products(title text, price float) html_strip = '1'
POST /cli -d "
CREATE TABLE products(title text, price float) html_strip = '1'"
$index = new \Manticoresearch\Index($client);
$index->setName('products');
$index->create([
'title'=>['type'=>'text'],
'price'=>['type'=>'float']
],[
'html_strip' => '1'
]);
utilsApi.sql('CREATE TABLE products(title text, price float) html_strip = \'1\'')
await utilsApi.sql('CREATE TABLE products(title text, price float) html_strip = \'1\'')
res = await utilsApi.sql('CREATE TABLE products(title text, price float) html_strip = \'1\'');
utilsApi.sql("CREATE TABLE products(title text, price float) html_strip = '1'");
utilsApi.Sql("CREATE TABLE products(title text, price float) html_strip = '1'");
utils_api.sql("CREATE TABLE products(title text, price float) html_strip = '1'", Some(true)).await;
table products {
html_strip = 1
type = rt
path = tbl
rt_field = title
rt_attr_uint = price
}
html_index_attrs = img=alt,title; a=title;
html_index_attrs 选项允许您指定即使其他 HTML 标记被去除,也应被索引的 HTML 标记属性。默认值为空,表示不索引任何属性。
该选项的格式是按标签列举可索引属性,如上例所示。指定属性的内容将被保留并索引,提供了一种从全文数据中提取额外信息的方法。
CREATE TABLE products(title text, price float) html_index_attrs = 'img=alt,title; a=title;' html_strip = '1'
POST /cli -d "
CREATE TABLE products(title text, price float) html_index_attrs = 'img=alt,title; a=title;' html_strip = '1'"
$index = new \Manticoresearch\Index($client);
$index->setName('products');
$index->create([
'title'=>['type'=>'text'],
'price'=>['type'=>'float']
],[
'html_index_attrs' => 'img=alt,title; a=title;',
'html_strip' => '1'
]);
utilsApi.sql('CREATE TABLE products(title text, price float) html_index_attrs = \'img=alt,title; a=title;\' html_strip = \'1\'')
await utilsApi.sql('CREATE TABLE products(title text, price float) html_index_attrs = \'img=alt,title; a=title;\' html_strip = \'1\'')
res = await utilsApi.sql('CREATE TABLE products(title text, price float) html_index_attrs = \'img=alt,title; a=title;\' html_strip = \'1\'');
utilsApi.sql("CREATE TABLE products(title text, price float) html_index_attrs = \'img=alt,title; a=title;\' html_strip = '1'");
utilsApi.Sql("CREATE TABLE products(title text, price float) html_index_attrs = \'img=alt,title; a=title;\' html_strip = '1'");
utils_api.sql("CREATE TABLE products(title text, price float) html_index_attrs = \'img=alt,title; a=title;\' html_strip = '1'", Some(true)).await;
table products {
html_index_attrs = img=alt,title; a=title;
html_strip = 1
type = rt
path = tbl
rt_field = title
rt_attr_uint = price
}
html_remove_elements = element1[, element2, ...]
一个 HTML 元素列表,其内容及元素本身将被去除。可选,默认值为空字符串(不去除任何元素内容)。
此选项允许您去除元素的内容,即开闭标签之间的所有内容。它对于去除嵌入的脚本、CSS 等非常有用。空元素的短标签形式(例如
)被正确支持,且该标签之后的文本不会被去除。
该值是以逗号分隔的元素(标签)名称列表,指定应去除其内容。标签名称不区分大小写。
CREATE TABLE products(title text, price float) html_remove_elements = 'style, script' html_strip = '1'
POST /cli -d "
CREATE TABLE products(title text, price float) html_remove_elements = 'style, script' html_strip = '1'"
$index = new \Manticoresearch\Index($client);
$index->setName('products');
$index->create([
'title'=>['type'=>'text'],
'price'=>['type'=>'float']
],[
'html_remove_elements' => 'style, script',
'html_strip' => '1'
]);
utilsApi.sql('CREATE TABLE products(title text, price float) html_remove_elements = \'style, script\' html_strip = \'1\'')
await utilsApi.sql('CREATE TABLE products(title text, price float) html_remove_elements = \'style, script\' html_strip = \'1\'')
res = await utilsApi.sql('CREATE TABLE products(title text, price float) html_remove_elements = \'style, script\' html_strip = \'1\'');
utilsApi.sql("CREATE TABLE products(title text, price float) html_remove_elements = \'style, script\' html_strip = '1'");
utilsApi.Sql("CREATE TABLE products(title text, price float) html_remove_elements = \'style, script\' html_strip = '1'");
utils_api.sql("CREATE TABLE products(title text, price float) html_remove_elements = \'style, script\' html_strip = '1'", Some(true)).await;
table products {
html_remove_elements = style, script
html_strip = 1
type = rt
path = tbl
rt_field = title
rt_attr_uint = price
}
index_sp = {0|1}
控制句子和段落边界的检测和索引。可选,默认值为 0(不检测也不索引)。
此指令启用句子和段落边界的检测和索引,使得 SENTENCE 和 PARAGRAPH 操作符能够工作。句子边界检测基于纯文本分析,只需设置 index_sp = 1 即可启用。段落检测则依赖于 HTML 标记,并在 HTML 去除过程 中进行。因此,要索引段落边界,必须同时将 index_sp 指令和 html_strip 指令设置为 1。
以下规则用于确定句子边界:
- 问号 (?) 和感叹号 (!) 总是表示句子边界。
- 句末点号 (.) 表示句子边界,除以下情况外:
- 当后面跟着一个字母时。这被视为缩写的一部分(例如 "S.T.A.L.K.E.R." 或 "Goldman Sachs S.p.A.")。
- 当后面跟着一个逗号时。这被视为缩写后跟逗号(例如 "Telecom Italia S.p.A., founded in 1994")。
- 当后面跟着一个空格和一个小写字母时。这被视为句子中的缩写(例如 "News Corp. announced in February")。
- 当前面跟着一个空格和一个大写字母,且后面跟着一个空格时。这被视为中间名的首字母(例如 "John D. Doe")。
段落边界在每个块级 HTML 标签处检测,包括:ADDRESS、BLOCKQUOTE、CAPTION、CENTER、DD、DIV、DL、DT、H1、H2、H3、H4、H5、LI、MENU、OL、P、PRE、TABLE、TBODY、TD、TFOOT、TH、THEAD、TR 和 UL。
句子和段落都会使关键字位置计数器增加 1。
CREATE TABLE products(title text, price float) index_sp = '1' html_strip = '1'
POST /cli -d "
CREATE TABLE products(title text, price float) index_sp = '1' html_strip = '1'"
$index = new \Manticoresearch\Index($client);
$index->setName('products');
$index->create([
'title'=>['type'=>'text'],
'price'=>['type'=>'float']
],[
'index_sp' => '1',
'html_strip' => '1'
]);
utilsApi.sql('CREATE TABLE products(title text, price float) index_sp = \'1\' html_strip = \'1\'')
await utilsApi.sql('CREATE TABLE products(title text, price float) index_sp = \'1\' html_strip = \'1\'')
res = await utilsApi.sql('CREATE TABLE products(title text, price float) index_sp = \'1\' html_strip = \'1\'');
utilsApi.sql("CREATE TABLE products(title text, price float) index_sp = \'1\' html_strip = '1'", true);
utilsApi.Sql("CREATE TABLE products(title text, price float) index_sp = \'1\' html_strip = '1'", true);
utils_api.sql("CREATE TABLE products(title text, price float) index_sp = \'1\' html_strip = '1'", Some(true)).await;
table products {
index_sp = 1
html_strip = 1
type = rt
path = tbl
rt_field = title
rt_attr_uint = price
}
index_zones = h*, th, title
字段内要索引的 HTML/XML 区域列表。默认值为空字符串(不索引任何区域)。
“区域”定义为开标签和匹配的闭标签之间的所有内容,所有共享相同标签名称的跨度都称为一个“区域”。例如,文档字段中 <H1> 和 </H1> 之间的所有内容属于 H1 区域。
index_zones 指令启用区域索引,但必须同时启用 HTML 剥离器(通过设置 html_strip = 1)。index_zones 的值应为以逗号分隔的标签名称和通配符(以星号结尾)的列表,用于作为区域索引。
区域可以嵌套和重叠,只要每个开标签都有匹配的闭标签。区域也可以用于使用 ZONE 操作符进行匹配,如 extended_query_syntax 中所述。
CREATE TABLE products(title text, price float) index_zones = 'h, th, title' html_strip = '1'
POST /cli -d "
CREATE TABLE products(title text, price float) index_zones = 'h, th, title' html_strip = '1'"
$index = new \Manticoresearch\Index($client);
$index->setName('products');
$index->create([
'title'=>['type'=>'text'],
'price'=>['type'=>'float']
],[
'index_zones' => 'h*,th,title',
'html_strip' => '1'
]);
utilsApi.sql('CREATE TABLE products(title text, price float) index_zones = \'h, th, title\' html_strip = \'1\'')
await utilsApi.sql('CREATE TABLE products(title text, price float) index_zones = \'h, th, title\' html_strip = \'1\'')
res = await utilsApi.sql('CREATE TABLE products(title text, price float) index_zones = \'h, th, title\' html_strip = \'1\'');
utilsApi.sql("CREATE TABLE products(title text, price float) index_zones = 'h, th, title' html_strip = '1'", true);
utilsApi.Sql("CREATE TABLE products(title text, price float) index_zones = 'h, th, title' html_strip = '1'", true);
utils_api.sql("CREATE TABLE products(title text, price float) index_zones = 'h, th, title' html_strip = '1'", Some(true)).await;
table products {
index_zones = h*, th, title
html_strip = 1
type = rt
path = tbl
rt_field = title
rt_attr_uint = price
}
Last modified: August 28, 2025