Case insensitive search on keyword

My index looks something like this:

    {
      "mappings": {
    "properties": {
      "id":    { "type": "integer" },  
      "clientId":  { "type": "integer"}, 
      "status":   { "type": "keyword"  },     
      "registration":   { "type": "keyword"  },     
      "model":   { "type": "keyword"  },     
      "make":   { "type": "keyword"  },
      "series":   { "type": "keyword"  },   
      "variant":   { "type": "keyword"  },    
    }
    }

I'm mostly using facets for my search so case sensitivity doesn't matter too much, however, i do have a few use-cases where i'd like the elastic search query to be case insensitive but it would like to results to be returned in their original form to display on the UI.

For example, if I've got a document where make: Ford i want it to match for all of these - 'Ford', 'ford', 'FORD' etc but when the actual document is returned i want it to keep the original value which is 'Ford'

What's the best way to do this?

You can use multifields for this. Look at fields | Elasticsearch Guide [7.12] | Elastic

The full example in this page shows that in action.

1 Like

Awesome, that seems to be exactly what I'm after!

Looks like i can update the existing mappings too without having to reindex

You will need to reindex as new fields (even sub fields) won't be generated again.
I guess you can run an empty update by query on all documents.

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