Write tutorial on using Weighting.final()
When you finally get around to writing tutorials, include one about using the Weighting.final() method to influence document scores based on a document popularity factor stored somewhere else.
class MyWeighting(scoring.BM25F): def final(searcher, docnum, score): # Let's say your model associates a document ID with the hit count # for each document, and the document ID is in the "id" stored field.
# First, get the contents of the "id" field for this document docid = searcher.stored_fields(docnum)["id"]
# Look up the document's hit count in my model maxhits = mymodel.max_hits() hitcount = mymodel.get_hits(docid)
# Multiply the computed score for this document by the popularity return score * (hitcount / maxhits) }}}