我们正在用弹性替换谷歌网站搜索并尝试匹配所有功能(前缀搜索,短语搜索,模糊搜索+拼写纠正,多语言)。经过几次尝试后,我得到了一个很好的解决方案,它结合了match_phrase_prefix,query_string和(降级)fuzzy_like_this。我希望有更简单的方法来做到这一点?
以下是我对荷兰语和示例查询的设置。
"settings":{
"analysis":{
"filter":{
"nl_stop_filter":{
"stopwords":[
"_dutch_"
],
"type":"stop"
},
"nl_stem_filter":{
"type":"stemmer",
"name":"dutch"
}
},
"analyzer":{
"article_analyzer":{
"filter":[
"icu_normalizer",
"nl_stop_filter",
"icu_folding"
],
"type":"custom",
"tokenizer":"icu_tokenizer"
}
}
}
}
查询:
"query": {
"filtered": {
"query": {
"bool": {
"should": [
{
"match_phrase_prefix": {
"_all": "je telefoon nummer"
}
},
{
"query_string": {
"query": "je telefoon nummer"
}
},
{
"fuzzy_like_this": {
"like_text": "je telefoon nummer",
"fuzziness": "AUTO",
"boost": 0.5
}
}
]
}
}
}
},
"highlight": {
"fields": {
"title": {
"fragment_size": 300,
"number_of_fragments": 1
},
"body": {
"fragment_size": 150,
"number_of_fragments": 2
}
}
}