忽略停用词

停用词是在索引和搜索过程中被忽略的词,通常由于其高频率且对搜索结果价值较低。

Manticore Search 默认对停用词应用词干提取,这可能导致不理想的结果,但可以通过使用stopwords_unstemmed来关闭此功能。

小型停用词文件存储在表头中,嵌入文件的大小有限制,该限制由embedded_limit选项定义。

停用词不被索引,但会影响关键词的位置。例如,如果“the”是停用词,文档1包含短语“in office”,而文档2包含短语“in the office”,搜索“in office”作为精确短语时只会返回第一个文档,尽管第二个文档中的“the”作为停用词被跳过。此行为可以通过stopword_step指令进行修改。

stopwords

stopwords=path/to/stopwords/file[ path/to/another/file ...]

stopwords 设置是可选的,默认为空。它允许你指定一个或多个停用词文件的路径,路径之间用空格分隔。所有文件都会被加载。在实时模式下,只允许使用绝对路径。

停用词文件格式为简单的 UTF-8 编码纯文本。文件数据将根据charset_table设置进行分词,因此你可以使用与索引数据相同的分隔符。

停用词文件可以手动或半自动创建。indexer 提供了一个模式,可以创建按关键词频率排序的表频率字典。该字典中的热门关键词通常可以用作停用词。详情请参见--buildstops--buildfreqs开关。该字典中的热门关键词通常可以用作停用词。

‹›
  • SQL
  • JSON
  • PHP
  • Python
  • Python-asyncio
  • javascript
  • Java
  • C#
  • Rust
  • CONFIG
📋
CREATE TABLE products(title text, price float) stopwords = '/usr/local/manticore/data/stopwords.txt /usr/local/manticore/data/stopwords-ru.txt /usr/local/manticore/data/stopwords-en.txt'

或者你可以使用 Manticore 自带的默认停用词文件。目前提供了50种语言的停用词。以下是它们的完整别名列表:

  • af - 南非荷兰语
  • ar - 阿拉伯语
  • bg - 保加利亚语
  • bn - 孟加拉语
  • ca - 加泰罗尼亚语
  • ckb- 库尔德语
  • cz - 捷克语
  • da - 丹麦语
  • de - 德语
  • el - 希腊语
  • en - 英语
  • eo - 世界语
  • es - 西班牙语
  • et - 爱沙尼亚语
  • eu - 巴斯克语
  • fa - 波斯语
  • fi - 芬兰语
  • fr - 法语
  • ga - 爱尔兰语
  • gl - 加利西亚语
  • hi - 印地语
  • he - 希伯来语
  • hr - 克罗地亚语
  • hu - 匈牙利语
  • hy - 亚美尼亚语
  • id - 印度尼西亚语
  • it - 意大利语
  • ja - 日语
  • ko - 韩语
  • la - 拉丁语
  • lt - 立陶宛语
  • lv - 拉脱维亚语
  • mr - 马拉地语
  • nl - 荷兰语
  • no - 挪威语
  • pl - 波兰语
  • pt - 葡萄牙语
  • ro - 罗马尼亚语
  • ru - 俄语
  • sk - 斯洛伐克语
  • sl - 斯洛文尼亚语
  • so - 索马里语
  • st - 索托语
  • sv - 瑞典语
  • sw - 斯瓦希里语
  • th - 泰语
  • tr - 土耳其语
  • yo - 约鲁巴语
  • zh - 中文
  • zu - 祖鲁语

例如,要使用意大利语的停用词,只需在配置文件中添加以下行:

‹›
  • SQL
  • JSON
  • PHP
  • Python
  • Python-asyncio
  • javascript
  • Java
  • C#
  • Rust
  • CONFIG
📋
CREATE TABLE products(title text, price float) stopwords = 'it'

如果你需要使用多种语言的停用词,应列出所有别名,RT模式下用逗号分隔,普通模式下用空格分隔:

‹›
  • SQL
  • JSON
  • PHP
  • Python
  • Python-asyncio
  • javascript
  • Java
  • C#
  • Rust
  • CONFIG
📋
CREATE TABLE products(title text, price float) stopwords = 'en, it, ru'

stopword_step

stopword_step={0|1}

stopwords 的 position_increment 设置是可选的,允许的值为0和1,默认值为1。

‹›
  • SQL
  • JSON
  • PHP
  • Python
  • Python-asyncio
  • javascript
  • Java
  • C#
  • Rust
  • CONFIG
📋
CREATE TABLE products(title text, price float) stopwords = 'en' stopword_step = '1'

stopwords_unstemmed

stopwords_unstemmed={0|1}

Whether to apply stop words before or after stemming. Optional, default is 0 (apply stop word filter after stemming).

By default, stop words are stemmed themselves, and then applied to tokens after stemming (or any other morphology processing). This means that a token is stopped when stem(token) is equal to stem(stopword). This default behavior can lead to unexpected results when a token is erroneously stemmed to a stopped root. For example, "Andes" might get stemmed to "and", so when "and" is a stopword, "Andes" is also skipped.

However, you can change this behavior by enabling the stopwords_unstemmed directive. When this is enabled, stop words are applied before stemming (and therefore to the original word forms), and the tokens are skipped when the token is equal to the stopword.

‹›
  • SQL
  • JSON
  • PHP
  • Python
  • Python-asyncio
  • javascript
  • Java
  • C#
  • Rust
  • CONFIG
📋
CREATE TABLE products(title text, price float) stopwords = 'en' stopwords_unstemmed = '1'
Last modified: August 28, 2025