我想要执行精确的单词匹配和部分单词/子串匹配.例如,如果我搜索"男士剃须刀",那么我应该能够在结果中找到"男士剃须刀".但是在我搜索"en的剃须刀"的情况下,我也应该能够在结果中找到"男士剃须刀".我使用以下设置和映射:
索引设置:
PUT /my_index
{
"settings": {
"number_of_shards": 1,
"analysis": {
"filter": {
"autocomplete_filter": {
"type": "edge_ngram",
"min_gram": 1,
"max_gram": 20
}
},
"analyzer": {
"autocomplete": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"lowercase",
"autocomplete_filter"
]
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
映射:
PUT /my_index/my_type/_mapping
{
"my_type": {
"properties": {
"name": {
"type": "string",
"index_analyzer": "autocomplete",
"search_analyzer": "standard"
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
插入记录:
POST /my_index/my_type/_bulk
{ "index": { "_id": 1 }}
{ "name": "men's shaver" }
{ "index": { "_id": 2 …
Run Code Online (Sandbox Code Playgroud)