使用以下索引,在metricname_text
上,假设我们有一个包含字符串1048avg_percent_memory_used
的文档。我发现如果我为搜索结果键入1048
,我会找到它。但是,如果我输入percent_memory
,则无法找到任何结果。有人能指出我在正确的方向上正确的方向用来部分匹配一个单词,但不一定从单词的开头锚定?我也不确定我match
查询是否是正确的搜索类型。
{
"settings": {
"analysis": {
"filter": {
"autocomplete_filter": {
"type": "edge_ngram",
"min_gram": 1,
"max_gram": 20
}
},
"analyzer": {
"autocomplete": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"lowercase",
"autocomplete_filter"
]
}
}
}
},
"mappings": {
"metric": {
"properties": {
"metricname_text": {
"type": "text",
"analyzer": "autocomplete"
},
}
}
}
}
答案 0 :(得分:0)
metadata = {
"settings": {
"analysis": {
"filter": {
"trigrams_filter": {
"type": "ngram",
"min_gram": 3,
"max_gram": 3
}
},
"analyzer": {
"trigrams": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"lowercase",
"trigrams_filter"
]
}
}
}
},
"mappings": {
"metric": {
"properties": {
"metricname_text": {
"type": "text",
"analyzer": "trigrams"
},
}
}
}
}