AFAIK to do a case insensitive search in ES requires a lowercase analyser ... Can this be done on a global level, short of mapping individual fields?
Sorry - to clarify ... I know that using the Searchkick syntax the default string uses lowercase:
> Contact.search('eric').count
=> 1
> Contact.search('Eric').count
=> 1
But I want to search on multiple text fields, and the the match becomes case sensitive:
> Contact.search('*', where: {first_name: ['Eric'] }).count
=> 1
> Contact.search('*', where: {first_name: ['eric'] }).count
=> 0
> Contact.search(query: {query_string: {default_field: 'first_name', query: "Eric"}}).count
=> 1
> Contact.search(query: {query_string: {default_field: 'first_name', query: "eric"}}).count
=> 0
I can't find any type of ES query condition that will allow me to do what the Searchkick default query is obviously doing
There's not an easy way to do this right now. Your best bet is to fork the gem and remove the lowercase token filters.
https://github.com/ankane/searchkick/blob/master/lib/searchkick/reindex.rb#L97
Just ran into this, I'd think it would be common enough to warrant some kind of option when building the query. Loving searchkick despite it though!
Three-year Bump?
Case-insensitive search is what most of our clients seem to want.
@jakcharlton Search is case-insensitive. where option is case-sensitive (just like SQL).
Most helpful comment
Just ran into this, I'd think it would be common enough to warrant some kind of option when building the query. Loving searchkick despite it though!