Searching multiple attributes on the same model

0 views
Skip to first unread message

Avishai

unread,
Nov 8, 2009, 1:30:39 PM11/8/09
to Thinking Sphinx
Hi, I have defined my index as

define_index do
...
has sex
has sex_seeking
has age
has min_age
has max_age
...
end

and I'm trying to search against it, but every way I try to do it, TS
seems to ignore the :sex => current_user.sex_seeking parameter, and
shows me only females (in the database, the data is stored as "M" and
"F".

@users = User.search(:with => {:age => min_age...max_age, :sex =>
current_user.sex_seeking}, :lat => degrees_to_radians
(current_user.lat.to_f), :lng => degrees_to_radians
(current_user.lng.to_f), :order => "@geodist ASC, created_at
DESC", :page => params[:page])

Does anyone know why this is happening?

Thanks a lot,

Avishai

Pat Allan

unread,
Nov 11, 2009, 10:36:00 PM11/11/09
to thinkin...@googlegroups.com
Hi Avishai

Unfortunately, you can't filter on string attributes, you can only
sort by them. Sphinx doesn't store them as strings, and so it can't
compare the values. I've just added a section to the documentation
site about this, and possible changes that may get you the solution
you'd like:
http://freelancing-god.github.com/ts/en/common_issues.html#string_filters

--
Pat
Reply all
Reply to author
Forward
0 new messages