Hi Eric

The reason geo searches won't work when searching on Business is because you 
have an array of floats (which Sphinx can't handle) for both latitude and 
longitude. Sphinx requires single float values for both of those attributes.

So, you probably want to search on Addresses instead, and maybe group by 
business_id, to ensure businesses don't get duplicated in the search results.
http://freelancing-god.github.com/ts/en/searching.html#grouping

It's also worth noting that your business model has an address_id attribute - 
you probably want to refer to the has_many collection instead?
  has addresses(:id), :as => :address_ids

Don't forget that Sphinx doesn't understand SQL syntax for conditions - so your 
physical_only scope will not work at all.

And I think the web_only scope failure is due to another small error - you've 
explicitly labelled the attribute as :web_only, but using :website_only in the 
scope. Also, it's best to keep attribute filters in :with, and field-focused 
queries in :conditions... so:

  sphinx_scope(:web_only) {
    {:with => {:web_only => true}}
  }

Hopefully this gets things working for you.

Cheers

-- 
Pat

On 24/01/2010, at 1:13 PM, Eric Lubow wrote:

> I am struggling with trying to geo search an asssociated model.  My
> relevant code is here: http://www.pastie.org/790850
> 
> The context is that I have a business model and an address model.  I
> want to be able to search for items in the business model that match
> certain criteria (like the name or description) and fall within n
> miles of a point the user enters.  If I search via the Address model,
> this works, but then I can't get it to search all the attributes of
> the model model.  If I search via the Business model, then I can't get
> the geo search to work (which is most likely because I am doing it
> wrong).  Is there a way to do this?
> 
> I also want to be able to search web_only businesses (which is defined
> via a sphinx_scope in the address model).  Basically a web_only
> business is a business where it's address has a website_only=1 in the
> SQL.  I also don't want businesses with website_only=1 returned in the
> geo query even if they have a lat/lng associated with them (hence the
> scope).  But when I put the scope in, Rails throws a no method error.
> Is there anything in the code that jumps out at anyone? Thanks in
> advance.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Thinking Sphinx" group.
> To post to this group, send email to thinking-sph...@googlegroups.com.
> To unsubscribe from this group, send email to 
> thinking-sphinx+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/thinking-sphinx?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Thinking Sphinx" group.
To post to this group, send email to thinking-sph...@googlegroups.com.
To unsubscribe from this group, send email to 
thinking-sphinx+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/thinking-sphinx?hl=en.

Reply via email to