Search code examples
ruby-on-railsthinking-sphinx

Thinking Sphinx: Querying only specific fields in a models index


Lots of Thinking Sphinx questions from me lately. Here's another one:

In some of my searches I'd like to only query some of all the fields included in my index definition. I can't seem to find any on this, the nearest thing being limiting the global search to specific models.

So.. is it possible to query only a given subset of fields in an index?


Solution

  • This is possible through Sphinx's extended match syntax:

    Model.search "@(name,description) ruby pancakes", :match_mode => :extended

    Where name and description are fields you're searching on, and 'ruby pancakes' is the search query.