Search any term startswith including special char

Hello All,
I have a field called title and it has value
"title" : "Toddler- $kitkat @taste &roll ^yart !here #you %ice ^oops *jam (pot) [beat] pep |old {jet} `egg /lol"

For given input i would like to match any term startswith the given input.
For example If i give #yo or ^oop or %ic it has to return the above document
query_string with field type text works for the above use case if no special char is there but with specical char it is not working. How to solve the usecase.
Query used
query_string : {
"fields": ["title", "title.keyword"],
"query": "^oo* %ic*"
}

if I use pe* then it fetches the documents

Hi there @Sankar_S , it sounds like you might want to use the Whitespace analyzer as the default analysis chain will strip out special characters.

1 Like

The field uses

"title" : {
          "type" : "text",
          "fields" : {
            "raw" : {
              "type" : "keyword"
            }
          },
          "analyzer" : "en_us_analyzer"
        },
"en_us_analyzer" : {
              "filter" : [
                "lowercase",
                "porter_stem",
                "asciifolding",
                "stop"
              ],
              "char_filter" : [
                "html_strip"
              ],
              "tokenizer" : "standard"
            }`Preformatted text`

reindexing it with whitespace tokenizer is the only possibility to solve this requirement?

hi there,

another option is you use the keyword field (non analyzed) and use a prefix match if you want to match on "starts with"

1 Like

requirement is to find document starts with any term/word in the field value.

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