Beena Shetty
Beena Shetty

Reputation: 3736

Wildcard search with Thinking Sphinx issue with indexes

define_index do
    indexes :first_name, :prefixes => true
    indexes :last_name, :prefixes => true
    indexes :email, :prefixes => true
    set_property :enable_star => 1
    set_property :min_perfix_len => 1
 end

In this case if i what to search for only email then it will search from all the indexes that are specified.

EG:

email ="*me*" 
Contact.search email

Displayed from first_name,last_name and email. But it should display from only email

What would be solution for searching only one index from the specified indexes.

Upvotes: 1

Views: 687

Answers (1)

pat
pat

Reputation: 16226

Just a quick correction - you want to search on a specific field, not a specific index.

And Thinking Sphinx can do this by using the :conditions option - so give the following a try:

Contact.search :conditions => {:email => '*me*'}

Thinking Sphinx can also automatically add wildcards to both ends of each word you give it as well:

Contact.search :conditions => {:email => 'me'}, :star => true

Upvotes: 1

Related Questions