A case-insensitive search

When we conduct a search, the search has to be case insensitive. This means that even if the user searches with capital letters in keywords, his/her search should avoid the casing of the characters and match keywords with any case. In short, the following should happen while indexing and searching:

 [ "ElasticSearch" , "elasticSearch" ] => "elasticsearch"

To enable a case-insensitive search, we need to design our analyzers accordingly. Once the analyzer is made, we need to simply apply it to the fields in the mapping. Let's see how we can achieve this:

  1. First, we need to create the analyzer:
    curl -X PUT "http://localhost:9200/news" -d '{ "analysis": { "analyzer": { "lowercase": { "type": "custom", "tokenizer": "standard", ...

Get Elasticsearch Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.