The gem and version I am using for sunspot is:
sunspot_rails gem version 1.2.1
rails version 2.3.18
The query I am trying to search with and search method is something like this:
query_params = { :name => 'Joe Smith',
:email => '[email protected]' }
How can I search a model with sunspot so that it searches via email or just name, since one can be blank for some searches (the below example did not work as expected)?
User.search do
fulltext(query_params[:name], :fields => :name)
fulltext(query_params[:email], :fields => :email)
end
* I have reindexed the models and the fields are all searchable within the model as well *
* EDIT *
The user.rb
model is set up like this:
class User < ActiveRecord::Base
searchable do
text :name
text :email
end
end