我有一個查詢像下面,Elasticsearch搜索查詢只返回精確匹配
任何想法,爲什麼我只得到確切的比賽結果時,我做搜索。例如 ;
當我搜索「的Aegli」我得到的結果,但是當我搜索「Aegl」未返回任何結果
query = {
"query": {
"query_string": {
"query": "%s"%q
}
},
"filter": {
"term": {
"has_product": 1
}
},
"facets": {
"destination": {
"terms": {
"field": "destination.en"
},
"facet_filter": {
"term": {
"has_product": 1
}
}
},
"hotel_class": {
"terms": {
"field": "hotel_class"
},
"facet_filter": {
"term": {
"has_product": 1
}
}
},
"hotel_type": {
"terms": {
"field": "hotel_type"
},
"facet_filter": {
"term": {
"has_product": 1
}
}
}
}
}
這就像Lucene的倒排索引應該工作的方式。您可以決定索引ngrams(但索引將快速增長)或使用通配符查詢(較慢)。 – javanna