I use Ultrasphinx gem plugin as a wrapper for accessing Sphinx search daemon.
My model declaration:
class Foo < ActiveRecord::Base
is_indexed :fields => ['content', 'private_notes', 'user_id']
Client code:
filters = {}
if type == "private"
# search only in `content` column
filters['user_id'] = current_user.id
else
# search in `content` and `private_notes` columns
end
results = Ultrasphinx::Search.new(:query => params[:query],
:per_page => 20,
:page => params[:page] || 1,
:filters => filters)
The problem I have now with Ultrasphinx gem(or Sphinx, in general?) is that it does not allow me to change set of fields where to look for matches IN RUNTIME
How can I solve this problem?