Ah, two geographic points in one search? Sorry, that's definitely something Sphinx can't do. I think two separate queries is your best bet, I'm afraid.
-- Pat On 18/05/2009, at 4:43 AM, anatoly wrote: > > Pat, either I do not understand your answer or I did not make my > question clear. I believe your suggestion would return users within a > distance of New York. But what I am trying to do is return users > within a distance of both New York and London. Essentially, trying > something like this (which does not work): > > :geo => [ [ @ny.lat, @ny.lng], [ @london.lat, @london.lng ] ] > > Thanks for your help. > > On May 18, 12:39 am, Pat Allan <[email protected]> wrote: >> Hi Anatoly >> >> What I'm thinking is that you make Location the searchable model - so >> have all references to users from within the Location define_index >> block. >> >> And then, do a grouped search - by user_id (which should be set up as >> an attribute), and sort the overall results by distance. >> >> Location.search( >> :geo => [[email protected], @ny.lng], >> :group_function => :attr, >> :group_by => "user_id", >> :order => "@geodist ASC, @relevance DESC" >> ) >> >> Add in :without => {:user_id => @user.id} to exclude the focused >> user, >> if needed. Now, I've no idea how nicely geo-location searching plays >> with grouping, but it's worth a shot, right? And, should it all go to >> plan, each location will have a distinct user. >> >> @locations.each_with_geodist do |location, distance| >> # location.user >> end >> >> Hope this helps. >> >> Cheers >> >> -- >> Pat >> >> On 17/05/2009, at 8:52 PM, anatoly wrote: >> >> >> >>> Another distance question. As far as I can tell there is no clean >>> solution for this, so wondering what suggestions may come out. >> >>> I have a User model which has many Locations. >>> So a User may have a Location in New York and a Location in London. >> >>> How would I go about doing a search for other Users within X >>> distance >>> of either New York or London, and then order the results by >>> distance? >> >>> One way of solving for this would be to do to separate searches, >>> combine the results, and order by distance. However, since there >>> can >>> be other search criteria, the combined results would have to be >>> sorted >>> by weight and then distance. >> >>> I am not sure if this will work right, and not exactly sure how to >>> even do that. >> >>> Any other suggestions? > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/thinking-sphinx?hl=en -~----------~----~----~----~------~----~------~--~---
