Lower case response from elastic search where as upper case is expected

618 Views Asked by At

I am trying to fetch data using elastic search with java using method .addAggregation(terms(term))

The JSON response that I am expecting is { "key" : "TEST" }

but I am getting the response as { "key" : "test" } which is in lower case, I want the response to be as it is stored. Please help here

1

There are 1 best solutions below

1
drjz On

The reason is that key is being analyzed e.g. lower-cased.

What you could do is have a "searchable" field that is being tokenized, but aggregate on a display field that preserves the casing. Or if you only want to aggregate (or if your search is case-sensitive and it seems for a field like key tokenization is also not desired) use the keyword type (https://www.elastic.co/guide/en/elasticsearch/reference/current/keyword.html)