ES 5.0 - case insensitive search for keyword fields


(Zaar Hai) #1

In ES 5.0, is there a way to treat the new keyword field in case-insensitive manner?


(David Pilato) #2

Not yet. See https://github.com/elastic/elasticsearch/issues/18064


(Zaar Hai) #3

That's too bad :frowning:

The ticket does not seem to active really. Do you have an idea when will it be available?


(David Pilato) #4

I believe it is planned for 5.1 but @jpountz might tell you more. (I know he is very active on this feature).


(Adrien Grand) #5

I know it doesn't look active since most work is happening in Lucene at the moment, but this is a feature that we know many users are interested in.


(Zaar Hai) #6

Thanks you guys. Looking forward to see it working soon.


(Derek White) #7

So what is the suggested workaround right now? Should using a text field with custom analyzer and enabling fielddata perform ok?


(Xudong You) #8

We used custom analyzer as workaround:

      "analyzer": {
        "lowercase_keyword": {
          "filter": "lowercase",
          "type": "custom",
          "tokenizer": "keyword"
        }
      }

(Taylor Lovett) #9

Doesn't that give a field data error?


(Fabiocatalao) #10

I've added a custom analyser:

"analyzer": {
"folding": {
"tokenizer": "standard",
"filter": [ "lowercase", "asciifolding" ]
}
},

I've also added a dynamic template in order to set the datatype of my fields. I've the following for keyword.

{
"string_as_keyword": {
"match_mapping_type": "string",
"match": "*_k",
"mapping": {
"type": "keyword",
"analyzer": "folding"
}
}
},

Is that correct? How can I query my data? I've found a lot of information about older versions but not for 5.0.


(David Pilato) #11

You can't add an analyzer to the keyword type.

In 5.2.0 you will be able to define a normalizer:

But if it's about search and not aggregations, then use a type text instead. It supports an analyzer.


(system) #13