0

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

user2681668
  • 161
  • 1
  • 2
  • 15
  • 1
    update your question with your mapping please: `curl -XGET localhost:9200/your-index` – Val Sep 27 '17 at 05:46
  • I guess it's more to do with the result data and the elastic search configurations, that I am getting the data response in the small case . rather than the way I query index isn't it? – user2681668 Sep 27 '17 at 06:05
  • Once I see your index settings it'll be clear :-) – Val Sep 27 '17 at 06:08
  • There are certain settings in your index that could affect it – Lucas Hendren Sep 27 '17 at 06:21
  • I am completely new to elasticsearch Can you please tell me where could I see those settings. – user2681668 Sep 27 '17 at 06:22
  • This is how I am forming the query, While normal curl call I am getting the data in the correct case, But while appliying aggrigation to it, I am facing the issue .getClient().prepareSearch(index).setTypes(type).setQuery(matchAllQuery()) .addAggregation(terms(term).field(field).size(0)).execute().actionGet(); – user2681668 Sep 27 '17 at 06:38

1 Answers1

0

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)

drjz
  • 648
  • 3
  • 10