This module contains classes for scoring (and sorting) search results.
This class provides backwards-compatibility with the old weighting class architecture, so any existing custom scorers don’t need to be rewritten.
It may also be useful for quick experimentation since you only need to override the score() method to try a scoring algorithm, without having to create an inner Scorer class:
class MyWeighting(Weighting):
def score(searcher, fieldname, text, docnum, weight):
# Return the docnum as the score, for some reason
return docnum
mysearcher = myindex.searcher(weighting=MyWeighting)
Implements the BM25F scoring algorithm.
>>> from whoosh import scoring
>>> # Set a custom B value for the "content" field
>>> w = scoring.BM25F(B=0.75, content_B=1.0, K1=1.5)
Parameters: |
|
---|
Chooses from multiple scoring algorithms based on the field.
The only non-keyword argument specifies the default Weighting instance to use. Keyword arguments specify Weighting instances for specific fields.
For example, to use BM25 for most fields, but Frequency for the id field and TF_IDF for the keys field:
mw = MultiWeighting(BM25(), id=Frequency(), keys=TF_IDF())
Parameters: |
|
---|
Wraps a weighting object and subtracts the wrapped model’s scores from 0, essentially reversing the weighting model.