lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Allan Hill <p...@metajure.com>
Subject norm for a document in a CustomScoreQuery
Date Fri, 10 Feb 2012 22:59:08 GMT
I was looking to the possibility that _some_ subqueries might discount (actually remove) field
norms.  I'm trying out the view that in general while looking for terms norm values seem appropriate,
but when searching for phrases that my custom query parsing has added to the query, the document
body length is not important.
I was looking into using SweetSpotSimilarity, but wanted to try a less drastic and less universal
solution, because SweetSpotSimilarity changes the norm for a field in all queries and subqueries.
 I thought to try this out by tweaking the score at query time - hence the use of a CustomScoreQuery.

This would be simple (even if ill advised) if I could find the field Norm for a document from
inside the custom query in the method:
CustomScoreProvider.customScore(int docId, float subQueryScore, float valSrcScore)

I'm thinking I can get the field norm component of the score using either

float docNormValue = Similarity.getDefault().decodeNormValue(reader.norms(KEY_FIELD)[docId]);
OR alternatively
float docNormValue = indexSearcher.getDefault().decodeNormValue(reader.norms(KEY_FIELD)[docId]);

Is this the right way to reach out to pick up the norm value, so I can remove it from the
calculation within one subquery?

I'm assuming my CustomScoreQuery (and Provider) knows the reader (all do) and in the second
case knows the indexSearcher.

And then I can mess up the score all I want :-)
Any thoughts by anyone if this is just too quirky?

-Paul


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message