使用 man ascii 来查看 ASCII 表。

首字母搜索,mec不能搜索木耳草

Elasticsearch | 作者 vance | 发布于2020年12月02日 | 阅读数:1073

索引配​置
"analyzer": {
"pinyin_analyzer": {
"tokenizer": "my_pinyin"
}
}

"tokenizer": {
"my_pinyin": {
"lowercase": "true",
"keep_original": "false",
"keep_first_letter": "true",
"keep_separate_first_letter": "true",
"type": "pinyin",
"limit_first_letter_length": "64",
"keep_full_pinyin": "true"
}


"properties": {
"name": {
"type": "keyword",
"py": {
"type": "text",
"analyzer": "pinyin_analyzer",
"search_analyzer": "pinyin_analyzer"
}
}
}


index time(木耳草)
{
"tokens": [
{
"token": "m",
"start_offset": 0,
"end_offset": 0,
"type": "word",
"position": 0
},
{
"token": "mu",
"start_offset": 0,
"end_offset": 0,
"type": "word",
"position": 0
},
{
"token": "e",
"start_offset": 0,
"end_offset": 0,
"type": "word",
"position": 1
},
{
"token": "er",
"start_offset": 0,
"end_offset": 0,
"type": "word",
"position": 1
},
{
"token": "c",
"start_offset": 0,
"end_offset": 0,
"type": "word",
"position": 2
},
{
"token": "cao",
"start_offset": 0,
"end_offset": 0,
"type": "word",
"position": 2
},
{
"token": "mec",
"start_offset": 0,
"end_offset": 0,
"type": "word",
"position": 2
}
]}

 
search time (mec)
{
"tokens": [
{
"token": "me",
"start_offset": 0,
"end_offset": 0,
"type": "word",
"position": 0
},
{
"token": "c",
"start_offset": 0,
"end_offset": 0,
"type": "word",
"position": 1
},
{
"token": "mec",
"start_offset": 0,
"end_offset": 0,
"type": "word",
"position": 1
}
] }

搜索时mec被分词结果中出现me,使用phrase query检索时,检索不出来。有没有解决方案??
已邀请:

要回复问题请先登录注册