lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Hostetter <hossman_luc...@fucit.org>
Subject Re: weight score based on a fields value
Date Thu, 23 Jun 2005 23:46:21 GMT

Your question can be read two ways...

1) score documents in which field "FFF" has value "VVV" slightly higher
   then documents in which field FFF does not contain value "VVV". (or any
   value)
2) score documents in which field "FFF" has some numeric value in such
   a way that the score of hte document is proportional to the value of
   the field

#2 is somewhat difficult, and would require a very customized Scorer.  I
haven't seen a general solution, but i really wish i had time to try
writting one.

#1 can be fairly straight forward using a BooleanQuery.

Assume "Query q" represents the query you normally would search on.
Assume "TermQuery fudge = new TermQuery("FFF","VVV")"

If q is an instanceof BooleanQuery, and at least once of the BooleanClauses is
"required" then you can add fudge to q as an optional sub-clause.  if q is
not a BooleanQuery, or q contains only optional clauses, then construct a
new BooleanQuery, and add q to it as a required clause, and fudge to it as
an optional clause.

now when you execute your search, the result set you get back should still
be the same, but documents containing the term FFF:VVV should have a
slightly increased score.

fudge.setBoost() can be used to change how much it affects the final
score.



: Date: Wed, 22 Jun 2005 11:33:46 -0500
: From: Dan Armbrust <daniel.armbrust.list@gmail.com>
: Reply-To: java-user@lucene.apache.org
: To: java-user@lucene.apache.org
: Subject: weight score based on a fields value
:
: Is there a straightforward way that I could change the scoring algorithm
: such that it would break ties based on looking at the value of a field?
: I'm not actually searching for the value in the field, so its not part
: of the query - I just want documents that have a particular field set to
: a particular value to score higher than documents that don't have that
: field set to that value - in cases where otherwise, they both would have
: scored the same.
:
: Thanks,
:
: Dan
:
: ---------------------------------------------------------------------
: To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
: For additional commands, e-mail: java-user-help@lucene.apache.org
:



-Hoss


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


Mime
View raw message