3
I have the following question, I have the model city(name, uf, province)
I’m trying to implement the Sunspot search method, but I’m getting it on my own:
# modelCity.rb
searchable do
text :name
end
# controller City
unless params[:search]
@cities = City.paginate(:page => params[:page], :order => "name ASC")
else
@search = City.search do
fulltext params[:search]
end
@cities = @search.results
end
City database:
1 Medianeira PR 3
2 Cascavel PR 4
3 Cascavemat PR 3
If I type for example "Rattlesnake" it brings the right search, but if I type "Bark" I want it to bring all the cities that have those words related to the name. Someone knows how I do it?
Although it works I think OP wants a solution to use with Solr and not in sql.
– Ismael