I have seen tons of articles on these, most of them for version 2.4. Since ES introduced keyword and text starting version 5.0, I wanted to check if there is a way to search on a keyword with case insensitivity.
Let's take an example. Following is my mapping:
PUT caseinsensitive
{
"mappings": {
"mytype": {
"properties": {
"exact_value": {
"type": "keyword"
}
}
}
}
}
Add a document to the index
PUT caseinsensitive/mytype/1
{
"exact_value": "Quick Foxes!"
}
SEARCH, that will not return any result because "q" and "f" are small case.
GET caseinsensitive/mytype/_search
{
"query": {
"term": {
"exact_value": "quick foxes!"
}
}
}
I have two questions:
- Is there a way to use keyword in the mapping and make the search case insensitive? I do expect everything else to match, except the case.
- Is there a way to search without case sensitivity and without changing the current mapping? Otherwise we would have to rebuild all the indices.
One use case is that, if I perform terms aggregation, I don't want two different buckets for same term with different cases (e.g. Seattle & seattle)
I found this article as one solution. Is that the best way? I believe this wouldn't use fieldData, so the performance impact is minimal. Please let me know.
Thanks so much.