Elastic Search aggregation query results are case incentive


(Srikanth Nagineni) #1

I am using ElasticSearch 6.2 Version. In the aggregation, query results are returned like `

Apple 10, apple 20, aPple 30

But I need all the names to be lower case and the final count will be

apple 60

Is there any way to get the aggregation results like my requirement.


(David Pilato) #2

Use a lowercase normalizer on your keyword field.


(Srikanth Nagineni) #3

This is mappings file:
"company_name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
},
},
"boost": 1.0,
"analyzer": "lowercase_analyzer",
},


(David Pilato) #4

Have a look at https://www.elastic.co/guide/en/elasticsearch/reference/current/normalizer.html


(Srikanth Nagineni) #5

@dadoonet It is working fine. Thank you!

In my case, I am having some special characters also like below:

Token - count
apple, inc - 20
apple inc - 10
apple inc, - 10
apple. inc - 20
apple.inc., - 10

I need the output like this:

Token - count
apple inc - 70

Is there any analyzer to satisfy my condition? If yes, Can you point me? Thank you!


(Srikanth Nagineni) #6

@dadoonet Got it. Just used custom analyzer and used that analyzer in normalize function.

"dot_pattern": {
"type": "pattern_replace",
"pattern": "\.",
"replacement": " "
}


(system) #7

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