I found a hack that's working so far:
I added an attribute for the length of the field like so
has "length(hotels.name)", :as => :name_length, :type => :integer
then I sort by it
:order => "@relevance DESC, name_length ASC", :sort_mode => :extended
Fortunately I'm only searching one field here or this wouldn't work
since I'd need to know which field the match was found in and then use
the length of that one.
Thanks for the suggestions though since I'd still like to find a
"right" way to do this.
Regards,
Gordon
On Tue, Mar 2, 2010 at 8:23 AM, Pat Allan <[email protected]> wrote:
> I think what you're after is having exact matches weighted over partial
> matches... it's a question that comes up here pretty regularly, though
> without any definitive solution.
>
> I don't know if changing the match mode (instead of the ranking mode) would
> have any better effect on the search:
> http://freelancing-god.github.com/ts/en/searching.html#matchmodes
>
> Though given your weights, I'm guessing you're using extended mode already?
> (Which is probably the best option).
>
> I'd recommend posting to the Sphinx forum (or at least, searching on there)
> to see if anyone there has a good idea on how it could be implemented.
> http://www.sphinxsearch.com/forum/
>
> --
> Pat
>
> On 02/03/2010, at 2:47 AM, gduq wrote:
>
>> When I search for "London"
>>
>> I'm getting "East London" as first result and "London" as second. I
>> checked the weights of the results using:
>>
>>>> results.class
>> => ThinkingSphinx::Search
>>>> results.each_with_weighting do |result,weight|
>> ?> puts result.name
>>>> puts weight
>>>> end
>>
>> and I can see they both have the same weight (30). I can understand
>> why since both match the entire search term.
>>
>> I've tried all the ranking modes from
>> http://freelancing-god.github.com/ts/en/searching.html#ranking
>> without any difference.
>>
>> Is there a way to get "London" to be ranked higher so it shows up
>> first in the results?
>>
>> P.S.
>> Sorry about the vague subject, but I really don't know what to call
>> this. Even if you can't tell me how to solve it but know what it's
>> called let me know since right now I don't even know what to google
>> for.
>>
>> --
>> 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.
>>
>
> --
> 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.
>
>
--
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.