@ankane How can i use postgres lower function in searchkick's where condition
I have below query which is working fine
klass.search(@params[:query], fields: [:name,:category_name],where: {or: [[{available_cities_name: "New Yo"},{available_cities_short_name: "NY"}]]}).hits
Now i want to use lower function but i am getting syntax error
klass.search(@params[:query],
fields: [:name,:category_name],
where: {
or: [ [
{"lower(available_cities_name) = ?", "New Yo"},
{"lower(available_cities_short_name) = ?", "ny"}
]]
}
).hits
I am getting below syntax error,
SyntaxError: unexpected '}', expecting end-of-input e_cities_name) = ?", "New Yo"},{"lower(available_cities_shor
Can somebody tell me how to use lower function in searchkick ?
Elasticsearch does not have a lower
function. To get around this, you can index a lowercase version of the field and query against that.
def search_data
{
available_cities_name: available_cities_name,
available_cities_name_lower: available_cities_name.downcase
}
end