Reputation: 116
How can I search in elasticsearch field by its exact value but with case insensitive query? For example I have field with value { "Type": "Płatność kartą" }, and my query will search by value "płatność kartą". I need to be able to search by list of string parameters (i.e. "płatność kartą", "płatność gotówką", etc.). I tried elastic TERMS query but it didn't return value when sensitive case difference appears. Field index is set to not_analyzed.
Upvotes: 1
Views: 1649
Reputation: 1130
If you choose not analyzed
when indexing, Elastic is not analyzing these terms at index time and that means they are stored verbatim. So when you are querying, you get no results as the query terms don't match the stored fields.
In order to be able to query with lowercase and get the uppercase results, too, you need to use an analyzer
on your mapping. Here are the available options from the docs.
If none the available analyzers fit you, you can define your custom one, by specifying the filters you want to be applied. For example, using just the lowercase
filter, Elastic will index the RegisteredPaymentType
field just lowercased. Then, while querying, the same analyzer will be applied to the query and you will get the expecting results.
Upvotes: 3