43 LOGCALL_VOID(MATCH,
"Weight::init_", stats | query_length | shard);
46 if (stats_needed & AVERAGE_LENGTH)
48 if (stats_needed & DOC_LENGTH_MAX)
50 if (stats_needed & DOC_LENGTH_MIN)
52 if (stats_needed & UNIQUE_TERMS_MAX)
54 if (stats_needed & UNIQUE_TERMS_MIN)
56 if (stats_needed & TOTAL_LENGTH)
58 if (stats_needed & DB_DOC_LENGTH_MAX)
60 if (stats_needed & DB_DOC_LENGTH_MIN)
62 if (stats_needed & DB_UNIQUE_TERMS_MAX)
64 if (stats_needed & DB_UNIQUE_TERMS_MIN)
70 query_length_ = query_length;
81 LOGCALL_VOID(MATCH,
"Weight::init_", stats | query_length |
term | wqf | factor | shard | postlist_void);
84 if (stats_needed & AVERAGE_LENGTH)
86 if (stats_needed & DOC_LENGTH_MAX)
88 if (stats_needed & DOC_LENGTH_MIN)
90 if (stats_needed & UNIQUE_TERMS_MAX)
92 if (stats_needed & UNIQUE_TERMS_MIN)
94 if (stats_needed & TOTAL_LENGTH)
96 if (stats_needed & WDF_MAX) {
97 auto postlist =
static_cast<LeafPostList*
>(postlist_void);
100 if (stats_needed & DB_DOC_LENGTH_MAX)
102 if (stats_needed & DB_DOC_LENGTH_MIN)
104 if (stats_needed & DB_UNIQUE_TERMS_MAX)
106 if (stats_needed & DB_UNIQUE_TERMS_MIN)
108 if (stats_needed & DB_WDF_MAX) {
115 if (stats_needed & (TERMFREQ | RELTERMFREQ | COLLECTION_FREQ)) {
117 termfreq_, reltermfreq_, collectionfreq_);
121 query_length_ = query_length;
132 LOGCALL_VOID(MATCH,
"Weight::init_", stats | query_length | factor | termfreq | reltermfreq | collection_freq | shard);
136 if (stats_needed & AVERAGE_LENGTH)
138 if (stats_needed & (DOC_LENGTH_MAX | WDF_MAX)) {
147 wdf_upper_bound_ = doclength_upper_bound_;
149 if (stats_needed & DOC_LENGTH_MIN)
151 if (stats_needed & UNIQUE_TERMS_MAX)
153 if (stats_needed & UNIQUE_TERMS_MIN)
155 if (stats_needed & TOTAL_LENGTH)
157 if (stats_needed & (DB_DOC_LENGTH_MAX | DB_WDF_MAX)) {
166 db_wdf_upper_bound_ = db_doclength_upper_bound_;
168 if (stats_needed & DB_DOC_LENGTH_MIN)
170 if (stats_needed & DB_UNIQUE_TERMS_MAX)
172 if (stats_needed & DB_UNIQUE_TERMS_MIN)
175 termfreq_ = termfreq;
176 reltermfreq_ = reltermfreq;
177 query_length_ = query_length;
178 collectionfreq_ = collection_freq;
183 Weight::~Weight() { }
192 Weight::serialise()
const
198 Weight::unserialise(
const string &)
const
212 Weight::get_maxextra()
const
225 Weight::create(
const string & s,
const Registry & reg)
227 const char *
p = s.c_str();
231 if (*
p ==
'\0')
break;
241 if (scheme ==
"trad") {
242 const char* params =
p;
255 return weight->create_from_parameters(
p);
259 Weight::create_from_parameters(
const char *)
const
Abstract base class for leaf postlists.
virtual Xapian::termcount get_wdf_upper_bound() const =0
Xapian::Weight subclass implementing the BM25 probabilistic formula.
Virtual base class for Database internals.
virtual termcount get_unique_terms_lower_bound() const
Get a lower bound on the unique terms size of a document in this DB.
virtual termcount get_doclength_upper_bound() const =0
Get an upper bound on the length of a document in this DB.
virtual termcount get_unique_terms_upper_bound() const
Get an upper bound on the unique terms size of a document in this DB.
virtual termcount get_doclength_lower_bound() const =0
Get a lower bound on the length of a document in this DB.
InvalidArgumentError indicates an invalid parameter value was passed to the API.
Registry for user subclasses.
const Xapian::Weight * get_weighting_scheme(std::string_view name) const
Get the weighting scheme given a name.
UnimplementedError indicates an attempt to use an unimplemented feature.
Class to hold statistics for a given collection.
static void parameter_error(const char *msg, const std::string &scheme, const char *params)
Xapian::totallength total_length
Total length of all documents in the collection.
bool get_stats(std::string_view term, Xapian::doccount &termfreq, Xapian::doccount &reltermfreq, Xapian::termcount &collfreq) const
Get the frequencies for the given term.
Xapian::termcount db_doclength_upper_bound
An upper bound on the maximum length of any document in the database.
Xapian::termcount db_doclength_lower_bound
A lower bound on the minimum length of any document in the database.
Xapian::termcount db_unique_terms_lower_bound
A lower bound on the number of unique terms in any document.
Xapian::doccount rset_size
Number of relevant documents in the collection.
Xapian::doccount collection_size
Number of documents in the collection.
static bool double_param(const char **p, double *ptr_val)
Xapian::doclength get_average_length() const
Xapian::termcount db_unique_terms_upper_bound
An upper bound on the number of unique terms in any document.
Abstract base class for weighting schemes.
#define LOGCALL_VOID(CATEGORY, FUNC, PARAMS)
Hierarchy of classes which Xapian can throw as exceptions.
Abstract base class for leaf postlists.
static void parameter_error(const char *message, const std::string &scheme, const char *params)
The Xapian namespace contains public interfaces for the Xapian library.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
Various assertion macros.
Xapian::Weight::Internal class, holding database and term statistics.