analysis-pinyin
analysis-pinyin copied to clipboard
使用 pinyin filter 影响短语查询
我看到使用了 拼音过滤器 后,词之间 position
变化了。这样会影响短语、近似查询!
比如 我爱我家 的分词结果:
{
"tokens": [
{
"token": "我爱",
"start_offset": 0,
"end_offset": 2,
"type": "rr",
"position": 0
},
{
"token": "woai",
"start_offset": 0,
"end_offset": 2,
"type": "nt",
"position": 1
},
{
"token": "我家",
"start_offset": 2,
"end_offset": 4,
"type": "n",
"position": 2
},
{
"token": "wojia",
"start_offset": 2,
"end_offset": 4,
"type": "n",
"position": 3
}
]
}
请问有没有更好的解决方式,目前我是通过 多字段 解决的,
{
"title": {
"type": "text",
"analyzer": "ik_max_word",
"fields": {
"pinyin": {
"type": "text",
"analyzer": "my_pinyin"
}
}
}
}
title
可以用近似查询,title.pinyin
可以进行拼音查询!