You can find each record's weight and distance in  
@locations.results[:matches] - a hash per result, with the  
sphinx_internal_id providing the Location id.

I've no idea whether relevance weightings are purely in relation to  
other results in the query, or considered a solid data point in  
relation to other queries as well. So that may play havoc with your  
results, unfortunately (although perhaps it's not a massive issue?).

-- 
Pat

On 18/05/2009, at 12:24 PM, anatoly wrote:

>
> I had a feeling it wasn't supported.  Is there a good what to combine
> and sort two search results?  Seems to me that each match has it's own
> weight and distance... and using these values (and maybe there is
> something else useful), there should be a way to merge to result sets
> and then sorting.  Is there some easy way of doing that?  (I am still
> learning the TS Collection object so not exactly sure how to parse
> through it).
>
> On May 18, 2:32 pm, Pat Allan <[email protected]> wrote:
>> 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?- Hide quoted text -
>>
>> - Show quoted text -
> >


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to