Back to All

Search works differently with mailadresses in /search and /admin/items - is there a setting where we can change this?

These work the same:
/search?term="[email protected]" -> 1 result
/admin/items?term="[email protected]" -> 1 result

These work differently:
/search?term=[email protected] -> 1 result
/admin/items?term=[email protected] -> 999 results (shows everybody in the company with "domain.com" anywhere within the item)

It seems /admin/item does not consider [email protected] to be one (1) string but many strings, divided by the @ sign.

Is there a setting we (or you) can adjust so they work the same?

ChatGPT suggests

To handle email addresses as single terms, you can configure a custom analyzer in your Elasticsearch index settings. This custom analyzer can use the keyword tokenizer, which treats the entire string as a single token. Here's how you can define and use a custom analyzer in your Elasticsearch index:

{
  "settings": {
    "analysis": {
      "analyzer": {
        "email_analyzer": {
          "type": "custom",
          "tokenizer": "keyword",
          "filter": ["lowercase"]
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "email": {
        "type": "text",
        "analyzer": "email_analyzer"
      }
    }
  }
}