为什么Elasticsearch无法检测到我的定制分析仪? [英] Why isn't Elasticsearch detecting my custom made analyzer?
本文介绍了为什么Elasticsearch无法检测到我的定制分析仪?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用一个名为"autocomplete"的定制分析器创建了一个用户名"索引:
I made an index "user-name" with a custom made analyzer called 'autocomplete':
client.indices.create({
index: 'user-name',
type: 'text',
settings: {
analysis: {
filter: {
autocomplete_filter: {
type: 'edge-ngram',
min_gram: 1,
max_gram: 20
}
},
analyzer: {
autocomplete: {
type: 'custom',
tokenizer: 'standard',
filter: [
'lowercase',
'autocomplete_filter'
]
}
}
}
}
}
然后,我尝试通过在映射中使用它来引用此定制分析器:
Then I try to reference this custom made analyzer by trying to use it in a mapping:
client.indices.putMapping({
index: 'user-name',
type: 'text',
body: {
properties: {
name: {
type: 'string',
analyzer: 'autocomplete',
search_analyzer: 'standard'
}
}
}
})
但随后出现此错误:原因":找不到字段[名称]的分析器[自动完成]".为什么未检测到我的自动完成分析器?谢谢.
but then I get this error: "reason": "analyzer [autocomplete] not found for field [name]". Why isn't my autocomplete analyzer being detected? Thanks.
推荐答案
您快到了.您只需要将索引settings
放在body
参数内即可
You're almost there. You simply need to put the index settings
inside the body
parameter:
client.indices.create({
index: 'user-name',
type: 'text',
body: {
settings: {
analysis: {
filter: {
autocomplete_filter: {
type: 'edge-ngram',
min_gram: 1,
max_gram: 20
}
},
analyzer: {
autocomplete: {
type: 'custom',
tokenizer: 'standard',
filter: [
'lowercase',
'autocomplete_filter'
]
}
}
}
}
}
}
这篇关于为什么Elasticsearch无法检测到我的定制分析仪?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文