Forum: Ferret Score more if begins with query

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Linus (Guest)
on 2007-03-21 18:57
Hi,
I need to score more on products, those names
begin with query, rather then just contain it.

I am not sure where to start research on that...
Any ideas?

Best regards,
Tom
Jens K. (Guest)
on 2007-03-22 11:30
(Received via mailing list)
On Wed, Mar 21, 2007 at 05:57:46PM +0100, Linus wrote:
> Hi,
> I need to score more on products, those names
> begin with query, rather then just contain it.
>
> I am not sure where to start research on that...
> Any ideas?

you could index the first word of your product names in a separate
field, and give that field a boost. So any query with a term that
matches the first word of the product name would score higher.

however there might well be better solutions to this problem I can't
think of right now :-)

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
removed_email_address@domain.invalid | www.webit.de

Amtsgericht Dresden | HRB 15422
GF Sven Haubold, Hagen Malessa
Linus (Guest)
on 2007-03-23 19:08
Jens K. wrote:
> you could index the first word of your product names in a separate
> field, and give that field a boost. So any query with a term that
> matches the first word of the product name would score higher.
>
> however there might well be better solutions to this problem I can't
> think of right now :-)
I finished with this in controller:

q = "#{q}*^4 OR *#{q}*"

It seems to do the job :)

Best regards,
Tom
David B. (Guest)
on 2007-04-06 10:30
(Received via mailing list)
On 3/22/07, Linus <removed_email_address@domain.invalid> wrote:
> Hi,
> I need to score more on products, those names
> begin with query, rather then just contain it.
>
> I am not sure where to start research on that...
> Any ideas?

See SpanFirstQuery. It is especially designed for this. Unfortunately
you can't build one with the query parser. You need to build it by
hand.

http://ferret.davebalmain.com/api/classes/Ferret/S...
This topic is locked and can not be replied to.