If age is a column on the users table (and it sounds like it is) then you can
just refer to it directly in the `has` call:
has age
Then, you’ll need to run `rake ts:rebuild` to have the Sphinx configuration and
indices updated, and after that:
User.search params[:query], :with => {:age => 18..55}
If you’re using your user_age_range method, make sure it’s returning a range of
integers:
params[:start_age].to_i..params[:end_age].to_i
Cheers
—
Pat
> On 28 Nov 2014, at 5:10 am, alexa <[email protected]> wrote:
>
> I can successfully perform a age search using ThinkingSphinx if I do this in
> the controller:
>
> @users = User.where(age: user_age_range)
>
> private
> def user_age_range
> params[:start_age]..params[:end_age]
> end
>
> That requires no changes to the index. However it ignores all my previous
> rules with geo search distance, since I am overwriting my original @users =
> User.search(params[:query] by having two @users statements.
>
> I'm not sure how to adjust it using `age: user_age_range` with the @users =
> User.search(params[:query] .
>
> So I figured the best option would be to do a with condition, :with => { :age
> => 18..55 } and add age as a 'has' attribute so Sphinx can do that max
> computation. But setting up the 'has' attribute has been confusing for me
> lol. What should the age 'has' attribute look like if I am tying to do the
> with condition?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Thinking Sphinx" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected]
> <mailto:[email protected]>.
> To post to this group, send email to [email protected]
> <mailto:[email protected]>.
> Visit this group at http://groups.google.com/group/thinking-sphinx
> <http://groups.google.com/group/thinking-sphinx>.
> For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
--
You received this message because you are subscribed to the Google Groups
"Thinking Sphinx" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/thinking-sphinx.
For more options, visit https://groups.google.com/d/optout.