我正在使用弹性搜索 7.3,我的数据由以下字符串组成:K&S KS KS KS KS。当我搜索 KSI 时,没有得到任何 K&S 的结果。
我已经为这个问题尝试了归一化器,但仍然没有得到相关的结果。
这是索引定义:
"analysis": {
"analyzer": {
"my_analyzer": { # Defining our custom analyzer
"type": "custom",
"filter": [
"lowercase","word_delimiter"
],
"tokenizer": "whitespace" ,
"char_filter":["my_char_filter"] # Tokenizing by witespace
}
},
"char_filter":{
"quote": {
"type": "mapping",
"mappings": [
"< => \" \"",
"> => \" \"",
"= => \" \"",
"? => \" \"",
"! => \" \"",
"% => \" \"",
"/ => \" \"",
"& => \" \"",
'''" => \" \"''',
"' => \" \"",
"( => \" \"",
") => \" \"",
"+ => \" \"",
", => \" \"",
"[ => \" \"",
"] => \" \"",
"{ => \" \"",
"} => \" \"",
"- => \" \"",
". => \" \"",
"pvt => \" pvt \"",
"private => \" private \"",
"privatelimited => \" private limited \"",
"public => \" public \"",
"pub => \" pub \""
]
},
"my_char_filter": {
"type": "mapping",
"mappings": [
". => \" \"",
"& => \" \"",
"pvt => \" pvt \"",
"private => \" private \"",
"privatelimited => \" private limited \"",
"public => \" public \"",
"pub => \" pub \""
]
}
},
"normalizer": {
"my_normalizer": {
"type": "custom",
"char_filter": ["quote"],
}
}
}
},
"mappings": {
"properties": {
"companyname": {
"type": "whitespace", # KEYWORD
"analyzer": "my_analyzer", #Mapping Index Analyzer onto our custom analyzer
"search_analyzer": "my_analyzer", #Mapping Search Analyzer onto our custom analyzer
"search_quote_analyzer": "my_analyzer" , #Mapping Search Quote Analyzer (which is used to ignore removal of stopwords) onto our custom analyzer
"normalizer": "my_normalizer"
}
}
}
}
这是我的查询结构:
"query": {
"bool": {
"should": [
{"match": {
"companyname": {
'query': query ,
"fuzziness": 2,
}
}
}
]
}
}
结果必须包含有关 KS 的所有字符串。当我搜索 KS 时,结果应该是 K&S KS KS KS KS。