我想在默认的“ english ”中添加更多单词,例如“inc”、“incorporated”、“ltd”和“limited”。我怎样才能做到这一点?
我当前创建索引的代码如下。谢谢。
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"
]
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我的测试代码
POST my_index/_analyze
{
"analyzer": "my_analyzer",
"text": "House of Dickson<br> corp"
}
Run Code Online (Sandbox Code Playgroud)
我已经能够使用以下方法将自定义停用词与标准英语结合起来:
{
"analysis": {
"analyzer": {
"my_analyzer": {
"tokenizer": "standard",
"filter": [
"custom_stop",
"english_stop"
]
}
},
"filter": {
"custom_stop": {
"type": "stop",
"stopwords": ["custom1","custom2","custom3"]
},
"english_stop": {
"type": "stop",
"stopwords": "_english_"
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
“ english ”停用词集与标准分析器中的集相同。
您可以使用这些单词和附加停用词创建一个文件,并使用stopwords_path选项指向该文件(而不是stopwords设置):
{
"settings": {
"analysis": {
"filter": {
"my_stop": {
"type": "stop",
"stopwords_path": "stopwords/custom_english.txt"
}
},
...
}
Run Code Online (Sandbox Code Playgroud)
您可以在ES-docs中找到文件外观的更多信息(UTF-8,每行单个停用词,文件存在于所有节点上)。
| 归档时间: |
|
| 查看次数: |
2562 次 |
| 最近记录: |