我对 ElasticSearch 映射有疑问。例如字段的映射name
是:
{
"name": {
"type": "keyword",
"fields": {
"ngram": {
"type": "text",
"analyzer": "ngram_analyzer",
"search_analyzer": "ngram_analyzer"
},
"word": {
"type": "text",
"analyzer": "word_analyzer",
"search_analyzer": "word_analyzer"
}
}
}
}
整个映射有效search_analyzer
,但 ElasticSearch 似乎忽略了这一点。
分析设置:
{
"analysis":{
"analyzer":{
"ngram_analyzer":{
"type":"custom",
"char_filter":[
"number_char_filter_map",
"remove_duplicates"
],
"tokenizer":"ngram_tokenizer_whitespace",
"filter":[
"lowercase",
"english_stop"
]
},
"word_analyzer":{
"type":"custom",
"char_filter":[
"number_char_filter_map",
"remove_duplicates"
],
"tokenizer":"word_tokenizer",
"filter":[
"lowercase",
"english_stop"
]
}
},
"char_filter":{
"remove_duplicates":{
"type":"pattern_replace",
"pattern":"(.)(?=\\1)",
"replacement":""
},
"remove_white_spaces":{
"type":"pattern_replace",
"pattern":"(\s)",
"replacement":""
}
},
"filter":{
"english_stop":{
"type":"stop",
"ignore_case":true,
"stopwords":"_english_"
}
},
"tokenizer":{
"ngram_tokenizer":{
"type":"ngram",
"min_gram":2,
"max_gram":7
},
"ngram_tokenizer_whitespace":{
"type":"ngram",
"min_gram":2,
"max_gram":7,
"token_chars":[
"letter",
"digit",
"punctuation",
"symbol"
]
},
"word_tokenizer":{
"type":"standard"
}
}
}
}
根据 ElasticSearch 文档,我没有search_analyzer
在字段中找到任何定义。如果这种方法不起作用,是否有任何替代结构可以包含搜索分析器?