2017-07-09 23 views
0

我希望向默认的“英语”添加更多单词,例如“inc”,“incorporated”,“ltd”和“limited”。我怎样才能做到这一点?如何将停用词添加到ElasticSearch中的默认列表中

我目前创建索引的代码如下。谢谢。

PUT /my_index 
{ 
    "settings": { 
    "analysis": { 
     "filter": { 
     "my_stop": { 
      "type": "stop", 
      "stopwords": "_english_" 
     } 
     }, 
     "analyzer": { 
     "my_analyzer": { 
      "tokenizer": "whitespace", 
      "char_filter": [ 
      "html_strip" 
      ], 
      "filter": [ 
      "lowercase", 
      "asciifolding", 
      "my_stop" 
      ] 
     } 
     } 
    } 
    } 
} 

我的测试码

POST my_index/_analyze 
{ 
    "analyzer": "my_analyzer", 
    "text": "House of Dickson<br> corp" 
} 

回答

1

该组 “英语” 停止词是相同Standard Analyzer集合。

您可以创建这些话,你的额外停用词文件,并使用stopwords_path选项指向此文件(而不是stopwords设置):

{ 
    "settings": { 
    "analysis": { 
     "filter": { 
     "my_stop": { 
      "type": "stop", 
      "stopwords_path": "stopwords/custom_english.txt" 
     } 
     }, 
     ... 
} 

你可以找到更多信息的文件看起来应该像在ES-docs(UTF-8,每行单个停用词,所有节点上都存在文件)。

+0

谢谢。如果我使用Elastic Cloud(没有在本地安装ES),是否可以创建自定义停用字词文件? – Redzon

+0

我不使用Elastic Cloud,但我认为您需要在[Elastic Support Portal](https://support.elastic.co/customers/s/login/)中申请支持凭单。类似的情况在这里:[stopwords list upload](https://discuss.elastic.co/t/please-activate-synonyms-and-stopwords-list-upload/88124)。 – Joanna

相关问题