Elasticsearch 分析器配置
Elasticsearch analyzer config
我想为 Elasticsearch 中的任何索引设置一个全局分析器。
这些行添加到 elasticsearch.yaml:
index.analysis.analyzer.ik.type: ik
index.analysis.analyzer.default.type: ik
index.analysis.analyzer.standard.type: ik
重启Elasticsearch后,这些行显示在http://localhost:9200/_nodes/settings
index: {
analysis: {
analyzer: {
standard: {
type: "ik"
},
default: {
type: "ik"
},
ik: {
type: "ik"
}
}
}
}
然后我用urlhttp://localhost:9200/_analyze?text=时间&analyzer=ik
测试
{
tokens: [
{
token: "时间",
start_offset: 0,
end_offset: 2,
type: "CN_WORD",
position: 0
}
]
}
这表明IKAnalyzer 已启用。但是,当涉及到 http://localhost:9200/_analyze?text=时间&analyzer=standard 或 http://localhost:9200/_analyze?text= 时间时,返回 "standard" 分析器结果:
{
tokens: [
{
token: "时",
start_offset: 0,
end_offset: 1,
type: "<IDEOGRAPHIC>",
position: 0
},
{
token: "间",
start_offset: 1,
end_offset: 2,
type: "<IDEOGRAPHIC>",
position: 1
}
]
}
那么,我该怎么办?
默认分析器设置会影响真正的索引文档,而不是您使用 http://localhost:9200/_analyze 执行的 "test" 请求。尝试将少量文档添加到索引中,然后查看搜索是否如您所愿
我想为 Elasticsearch 中的任何索引设置一个全局分析器。
这些行添加到 elasticsearch.yaml:
index.analysis.analyzer.ik.type: ik
index.analysis.analyzer.default.type: ik
index.analysis.analyzer.standard.type: ik
重启Elasticsearch后,这些行显示在http://localhost:9200/_nodes/settings
index: {
analysis: {
analyzer: {
standard: {
type: "ik"
},
default: {
type: "ik"
},
ik: {
type: "ik"
}
}
}
}
然后我用urlhttp://localhost:9200/_analyze?text=时间&analyzer=ik
测试{
tokens: [
{
token: "时间",
start_offset: 0,
end_offset: 2,
type: "CN_WORD",
position: 0
}
]
}
这表明IKAnalyzer 已启用。但是,当涉及到 http://localhost:9200/_analyze?text=时间&analyzer=standard 或 http://localhost:9200/_analyze?text= 时间时,返回 "standard" 分析器结果:
{
tokens: [
{
token: "时",
start_offset: 0,
end_offset: 1,
type: "<IDEOGRAPHIC>",
position: 0
},
{
token: "间",
start_offset: 1,
end_offset: 2,
type: "<IDEOGRAPHIC>",
position: 1
}
]
}
那么,我该怎么办?
默认分析器设置会影响真正的索引文档,而不是您使用 http://localhost:9200/_analyze 执行的 "test" 请求。尝试将少量文档添加到索引中,然后查看搜索是否如您所愿