Case insensitive search by using query in java API

(JavaES) #1

Hi Team,
I have 10 indices and each index type contains on an average of 7 string fields,

Now i want to do case insensitive search on this fields of all index,i tried this setting & mapping

"analyzer": {
"lower_keyword": {
"type": "custom",
"filter": "lowercase",
"tokenizer": "keyword"

name": {
"type": "string",
"analyzer": "lower_keyword"

It's working fine ,

But instead of declaring analyzer in different index's and mapping at different field levels is there any way to handle or able to do case insensitive search by forming query in java API.

Thanks for the help in advance...

(David Pilato) #2

I'd use a template mapping so it would be applied automatically on every new index

(JavaES) #3

Thank you very much David ,but still if its adjustable from JAVA API Query will be very helpful for us as already we have it all in production. If somehow we can make independent from mapping

(David Pilato) #4

Can you describe a bit more what you have at this moment as a simple example so it will be easier to help you?

See this as an example: About the Elasticsearch category

(JavaES) #5

we have a index which is already in production ,and we have string field ,for this we don't have any analyser to lower case

For this filed we have value as Brand New ,but user is typing as brand new ,when we make a query search from java api ( term & match ) none of this worked.

we are looking for replica of SQL Lower function in elastic search ,where we will check by lower casing the filed value to the given search term

for ex: if user types as brand new /Brand New we will lower case this term
and also make the search on particular filed by lower casing that particular filed value to lower.


SELECT LOWER ('Elastic Seacrh Filed values');

(David Pilato) #6

Can you please create an elasticsearch script which reproduces what you have in production?

(JavaES) #7


"BrandName": {
"type": "string",
"index": "not_analyzed",
"fields": {
"raw": {
"type": "string"

In this filed Brand Name we have "Brand New"

Query serach build

"query" : {
"match" : {
"BrandName" : {
"query" : "brand new",
"type" : "boolean"

No response we are getting with this query ,as the actual value in ES DB is Brand New

(system) closed #9