Searching for words such as "c#" using app search

45 Views Asked by At

We are using Elasticsearch in combination with App Search to power our site's search pages. We've encountered an issue where we noticed that we can't search for keywords such as "C#", "C++" and alike. Does anyone have any advice on how we can overcome this problem?

1

There are 1 best solutions below

0
On

Hello its certainly that App search use by default the standard tokenizer that create only "C" token for "C#" and "C++"

POST _analyze
{
  "text": "C++",
  "tokenizer": "standard"
}

   =>

{
  "tokens" : [
    {
      "token" : "C",
      "start_offset" : 0,
      "end_offset" : 1,
      "type" : "<ALPHANUM>",
      "position" : 0
    }
  ]
}

You can try to use the solution provided in this blog https://medium.com/@joecwu/elastic-app-search-360f0eba04bf ( the Hacking: Custom our own index settings parts, but be sure to read all the post since it explains the app search behavior ) to override the default app search mapping. But its a bit hacky for production.