Ok I am doing it as such but it is ignoring the age search. For example I 
am doing 18-22 search for Males, and it's returning all Males regardless of 
their age.

Params being passed are gender=Male&start_age=18&end_age=23

In the view form is setup as:

select_tag :start_age, options_for_select((18..65)

select_tag :end_age, options_for_select((20..65)

The issue seems to be in the sphinx query:

  *Sphinx Query (0.9ms)*  SELECT GEODIST(0.5904448859496816, 
-1.464156709498043, latitude, longitude) AS geodist, * FROM `user_core` 
WHERE MATCH('@gender Male') AND `geodist` BETWEEN 0.0 AND 100000.0 AND 
`sphinx_deleted` = 0 AND `user_id` <> 1 ORDER BY `geodist` ASC LIMIT 0, 20

Is it required to pass the age param in the conditions method? As I'm doing 
that for gender :gender => params[:gender]

On Thursday, November 27, 2014 6:09:35 PM UTC-5, Pat Allan wrote:
>
> 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] <javascript:>> 
> 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] <javascript:>.
> To post to this group, send email to [email protected] 
> <javascript:>.
> Visit this group at http://groups.google.com/group/thinking-sphinx.
> For more options, visit 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.

Reply via email to