While searching a string I cannot retrieve strings which consist of a symbol(.,& ) between characters

---->

I am using elastic search 7.3, My data consists of strings like K&S K.S. K S KS KS. when I search for K S I don't get any result for K&S.

I have tried normalizer for this problem but still not getting relevant results.

this is the index definition:
//

 "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"
                }
            }
        }
    }

//
This is the query structure
//

"query": {
            "bool": {
                "should": [
                    {"match": {
                        "companyname": {
                            'query': query ,
                            "fuzziness": 2,
                            }
                        }
                    }
                ]
            }
        }

//

The result must contain all the string regarding K S . When I search for K S, result should be, K&S K S KS K.S. KS.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.