You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Felix Litman <f_...@pacbell.net> on 2007/01/23 19:01:00 UTC

proximity and location scoring

Is there a straightforward way to extend the "standard" parser to incorporate proximity into the score in multi-word queries, including boost factors?  I.e. score results higher when query terms appear closer toghether then when scattered?
   
  How about incorporating search term location in the score?  I.e. score results higher where terms appear closer to the beginning of the search field...
   
  Thank you,
  Felix

RE: proximity and location scoring

Posted by Chris Hostetter <ho...@fucit.org>.
: What about implementing a scoring policy that computes the score based
: only on which word position the term is matched?

if you wrote your own Similarity class and used SpanFirst queries that
should be possible.  It's the same basic principle as a Similarity
that scores entirely by tf, except that instead of tf being the only
method in your similarity class that doesn't return a 0 or 1, your
sloppyFreq method would be the only method returning something
interesting.


the Explanation class will be your best friend when debugging your code.



-Hoss


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


RE: proximity and location scoring

Posted by Chima Echeruo <ce...@mediosystems.com>.
 
What about implementing a scoring policy that computes the score based
only on which word position the term is matched? 

If the match occurred in the first word position, the score should be
highest, if in the second word position it would be least highest etc..
Finally for matches that share the same word position, alphabetic
sorting order will break ties.

In this scenario I expect exact or prefix matches only and don't care
how many times a term is matched or its inverse document frequency.

-c


-----Original Message-----
From: Doron Cohen [mailto:DORONC@il.ibm.com] 
Sent: Tuesday, January 23, 2007 10:56 AM
To: java-user@lucene.apache.org
Subject: Re: proximity and location scoring

Felix Litman <f_...@pacbell.net> wrote on 23/01/2007 10:01:00:

> Is there a straightforward way to extend the "standard" parser to 
> incorporate proximity into the score in multi-word queries, including 
> boost factors?

Current parser supports relaxed phrase syntax:
http://lucene.apache.org/java/docs/queryparsersyntax.html#Proximity%20Se
arches

>  I.e. score results higher when query terms appear closer toghether 
> then when scattered?

So for query "x y"~10 doc with "x a y" would score higher than doc with
"x a b y". You can control the effect of the distance, programmatically,
providing your own similarity class, especially sloppyFreq(int
distance);

(Doesn't help you much if you already knew all this but just looking for
how to extend the query parser...)

>
>   How about incorporating search term location in the score?  I.e.
> score results higher where terms appear closer to the beginning of the

> search field...

Current query parser (and syntax) does not support this, but see
http://lucene.apache.org/java/docs/api/org/apache/lucene/search/spans/Sp
anQuery.html

and all its sub-classes, especially SpanFirst and SpanNear - with both
scoring takes into account the distance between terms.

>
>   Thank you,
>   Felix


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: proximity and location scoring

Posted by Doron Cohen <DO...@il.ibm.com>.
Felix Litman <f_...@pacbell.net> wrote on 23/01/2007 10:01:00:

> Is there a straightforward way to extend the "standard" parser to
> incorporate proximity into the score in multi-word queries,
> including boost factors?

Current parser supports relaxed phrase syntax:
http://lucene.apache.org/java/docs/queryparsersyntax.html#Proximity%20Searches

>  I.e. score results higher when query terms
> appear closer toghether then when scattered?

So for query "x y"~10 doc with "x a y" would score
higher than doc with "x a b y". You can control the effect of the
distance, programmatically, providing your own similarity class,
especially sloppyFreq(int distance);

(Doesn't help you much if you already knew all this but just
looking for how to extend the query parser...)

>
>   How about incorporating search term location in the score?  I.e.
> score results higher where terms appear closer to the beginning of
> the search field...

Current query parser (and syntax) does not support this, but see
http://lucene.apache.org/java/docs/api/org/apache/lucene/search/spans/SpanQuery.html

and all its sub-classes, especially SpanFirst and SpanNear - with both
scoring takes into account the distance between terms.

>
>   Thank you,
>   Felix


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org