Is there a way I can get ferret to give the highest ranking to an
exact term match?
The problem I have right now is that I am searching both title and
body fields, so even if I boost the title field, if the body has more
instances of the query, then it gets pushed up in rank.
I would like for ferret to put exact matches (of the title field) at
the very top of the pile, so if I do a search for say “color”, the
results look like this
• Color
• Color Theory
• Color Management
Right now the order is like this
• Color Theory
• Color Management
• Color
Because the first two articles have more instances in the body field.
Is this possible?
On Wed, May 02, 2007 at 01:34:30PM +0200, Steven G. wrote:
Because the first two articles have more instances in the body field.
Is this possible?
If setting the boost for the title field really high (and the one for
the body really low, maybe even below 1) doesn’t help, you could run the
query twice, once against the title field only, and once against the
body.
Jens
–
Jens Krämer
webit! Gesellschaft für neue Medien mbH
Schnorrstraße 76 | 01069 Dresden
Telefon +49 351 46766-0 | Telefax +49 351 46766-66
[email protected] | www.webit.de
Amtsgericht Dresden | HRB 15422
GF Sven Haubold, Hagen Malessa
Setting the boost as you specified didn’t work.
How would I set up two queries?
My code: Parked at Loopia
On Wed, May 02, 2007 at 02:17:19PM +0200, Steven G. wrote:
Setting the boost as you specified didn’t work.
How would I set up two queries?
My code: Parked at Loopia
that should do the trick:
class Search
attr_accessor :query
def initialize(query)
@query = query
end
def do_search
returning [] do |results|
results << Term.multi_search(“title:(#{query})”, [Article, Term])
results << Term.multi_search(“#{query} -title:(#{query})”,
[Article, Term])
end
end
end
Jens
–
Jens Krämer
webit! Gesellschaft für neue Medien mbH
Schnorrstraße 76 | 01069 Dresden
Telefon +49 351 46766-0 | Telefax +49 351 46766-66
[email protected] | www.webit.de
Amtsgericht Dresden | HRB 15422
GF Sven Haubold, Hagen Malessa
For better compatibility with the code using your search model use aaf’s
SearchResults class:
def do_search
title_results = Term.multi_search( “title:(#{query})”,
[Article, Term] )
body_results = Term.multi_search( “#{query} -title:(#{query})”,
[Article, Term] )
new ActsAsFerret::SearchResults( title_results + body_results,
title_results.total_hits +
body_results.total_hits )
end
Jens
–
Jens Krämer
webit! Gesellschaft für neue Medien mbH
Schnorrstraße 76 | 01069 Dresden
Telefon +49 351 46766-0 | Telefax +49 351 46766-66
[email protected] | www.webit.de
Amtsgericht Dresden | HRB 15422
GF Sven Haubold, Hagen Malessa
I tried using the do_search method you suggested and get this error:
undefined method `SearchResults’ for ActsAsFerret:Module
On Sun, Jun 10, 2007 at 06:22:44PM -0700, Steven G. wrote:
I tried using the do_search method you suggested and get this error:
undefined method `SearchResults’ for ActsAsFerret:Module
my fault, correct syntax of course is
ActsAsFerret::SearchResults.new(…)
Jens
–
Jens Krämer
webit! Gesellschaft für neue Medien mbH
Schnorrstraße 76 | 01069 Dresden
Telefon +49 351 46766-0 | Telefax +49 351 46766-66
[email protected] | www.webit.de
Amtsgericht Dresden | HRB 15422
GF Sven Haubold, Hagen Malessa