ES 5.0 - case insensitive search for keyword fields

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

1 Like

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

That's too bad :frowning:

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

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

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.

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

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

We used custom analyzer as workaround:

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

Doesn't that give a field data error?

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.

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.

1 Like