だから私はこのインデックスを持っています
{
"settings":{
"index":{
"number_of_replicas":0,
"analysis":{
"analyzer":{
"default":{
"type":"custom",
"tokenizer":"keyword",
"filter":[
"lowercase",
"my_ngram"
]
}
},
"filter":{
"my_ngram":{
"type":"nGram",
"min_gram":2,
"max_gram":20
}
}
}
}
}
}
タイヤの宝石でこの検索を実行しています
{
"query":{
"query_string":{
"query":"xyz",
"default_operator":"AND"
}
},
"sort":[
{
"count":"desc"
}
],
"filter":{
"term":{
"active":true,
"_type":null
}
},
"highlight":{
"fields":{
"name":{
}
},
"pre_tags":[
"<strong>"
],
"post_tags":[
"</strong>"
]
}
}
「xyzpost」と「xyzquestion」という名前の2つの投稿があります。この検索を実行すると、強調表示されたフィールドが正しく返されます。
<strong>xyz</strong> question
<strong>xyz</strong> post
インデックスでmin_gramを1に変更し、インデックスを再作成するとすぐに、これが問題になります。強調表示されたフィールドは、このように戻ってきます
<strong>x</strong><strong>y</strong><strong>z</strong> pos<strong>xyz</strong>t
<strong>x</strong><strong>y</strong><strong>z</strong> questio<strong>xyz</strong>n
理由がわかりません。