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 Paul Allan Hill <pa...@metajure.com> on 2012/02/10 23:59:08 UTC

norm for a document in a CustomScoreQuery

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