26 #define XAPIAN_DEPRECATED(X) X
49 tout << *bigmset[start] <<
":" << bigmset[start].get_weight() <<
":"
50 << bigmset[start].get_percent() <<
"%\n";
55 min(start + size, bigmset.
size()));
62 bigmset[start + i].get_weight());
64 bigmset[start + i].get_percent());
71 vector<pair<Xapian::docid, double>>
weights;
72 vector<pair<Xapian::docid, double>>::const_iterator
i;
77 : weights(weights_), started(
false)
79 set_maxweight(max_wt);
85 PostingSource*
clone()
const override {
90 weights.push_back(make_pair(did, wt));
91 if (wt > get_maxweight()) set_maxweight(wt);
101 return weights.size();
104 return weights.size();
107 return weights.size();
120 return (i == weights.end());
126 return "MyPostingSource";
144 if (mset[1].get_percent() != 50)
break;
168 tout <<
"mset1 item = " << i.get_percent() <<
"%\n";
169 if (new_percent != percent) {
172 tout <<
"cutoff = " << percent <<
"%, "
173 "mset size = " << mset2.
size() <<
"\n";
175 percent = new_percent;
207 static const char *
const terms[] = {
"paragraph",
"banana" };
213 for (i = mset.
begin(); i != mset.
end(); ++i) {
246 TEST(mset[0].get_percent() < 100);
250 TEST_REL(mset[0].get_percent(), >=, 50);
256 TEST(mset[0].get_percent() < 100);
257 TEST_REL(mset[0].get_percent(), >=, 50);
269 TEST(mset[0].get_percent() < 100);
275 TEST_EQUAL(mset[0].get_percent(), mset2[0].get_percent());
281 for (
int i = 1; i <= 6; ++i) {
284 d.
add_term(
"boom", 2 + (i - 4)*(i - 2));
312 need_stat(DOC_LENGTH);
349 static const char *
const terms[] = {
"this",
"spoken",
"blank" };
355 TEST(mset[0].get_percent() != 100);
357 TEST_REL(mset[0].get_percent(), >, 1);
static Xapian::Query query(Xapian::Query::op op, const string &t1=string(), const string &t2=string(), const string &t3=string(), const string &t4=string(), const string &t5=string(), const string &t6=string(), const string &t7=string(), const string &t8=string(), const string &t9=string(), const string &t10=string())
static void make_topercent7_db(Xapian::WritableDatabase &db, const string &)
DEFINE_TESTCASE(consistency3, backend)
Xapian::Database get_database(const string &dbname)
test functionality of the Xapian API
Xapian::doccount get_termfreq_min() const override
A lower bound on the number of documents this object can return.
void reset(const Xapian::Database &, Xapian::doccount) override
Set this PostingSource to the start of the list of postings.
MyPostingSource(const vector< pair< Xapian::docid, double >> &weights_, double max_wt)
vector< pair< Xapian::docid, double > >::const_iterator i
Xapian::docid get_docid() const override
Return the current docid.
vector< pair< Xapian::docid, double > > weights
string get_description() const override
Return a string describing this object.
bool at_end() const override
Return true if the current position is past the last entry in this list.
void append_docweight(Xapian::docid did, double wt)
PostingSource * clone() const override
Clone the posting source.
void next(double) override
Advance the current position to the next matching document.
Xapian::doccount get_termfreq_max() const override
An upper bound on the number of documents this object can return.
Xapian::doccount get_termfreq_est() const override
An estimate of the number of documents this object can return.
double get_weight() const override
Return the weight contribution for the current document.
An indexed database of documents.
Xapian::doccount get_doccount() const
Get the number of documents in the database.
Class representing a document.
void add_boolean_term(std::string_view term)
Add a boolean filter term to the document.
void set_data(std::string_view data)
Set the document data.
void add_term(std::string_view term, Xapian::termcount wdf_inc=1)
Add a term to this document.
void set_weighting_scheme(const Weight &weight)
Set the weighting scheme to use.
MSet get_mset(doccount first, doccount maxitems, doccount checkatleast=0, const RSet *rset=NULL, const MatchDecider *mdecider=NULL) const
Run the query.
void set_sort_by_value_then_relevance(valueno sort_key, bool reverse)
Set the sorting to be by value, then by relevance for documents with the same value.
void set_cutoff(int percent_threshold, double weight_threshold=0)
Set lower bounds on percentage and/or weight.
void set_query(const Query &query, termcount query_length=0)
Set the query.
void set_sort_by_value(valueno sort_key, bool reverse)
Set the sorting to be by value only.
Iterator over a Xapian::MSet.
int get_percent() const
Convert the weight of the current iterator position to a percentage.
Class representing a list of search results.
Xapian::doccount size() const
Return number of items in this MSet object.
int convert_to_percent(double weight) const
Convert a weight to a percentage.
bool empty() const
Return true if this MSet object is empty.
MSetIterator begin() const
Return iterator pointing to the first item in this MSet.
MSetIterator end() const
Return iterator pointing to just after the last item in this MSet.
Base class which provides an "external" source of postings.
Class representing a query.
@ OP_XOR
Match documents which an odd number of subqueries match.
@ OP_AND
Match only documents which all subqueries match.
@ OP_OR
Match documents which at least one subquery matches.
@ OP_FILTER
Match like OP_AND but only taking weight from the first subquery.
Xapian::Weight subclass implementing the traditional probabilistic formula.
UnimplementedError indicates an attempt to use an unimplemented feature.
Abstract base class for weighting schemes.
This class provides read/write access to a database.
void commit()
Commit pending modifications.
Xapian::docid add_document(const Xapian::Document &doc)
Add a document to the database.
Weight * clone() const override
Clone this object.
double get_maxextra() const override
Return an upper bound on what get_sumextra() can return for any document.
double get_maxpart() const override
Return an upper bound on what get_sumpart() can return for any document.
double get_sumextra(Xapian::termcount doclen, Xapian::termcount, Xapian::termcount) const override
Calculate the term-independent weight component for a document.
double get_sumpart(Xapian::termcount, Xapian::termcount, Xapian::termcount, Xapian::termcount) const override
Calculate the weight contribution for this object's term to a document.
void init(double) override
Allow the subclass to perform any initialisation it needs to.
string str(int value)
Convert int to std::string.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
Convert types to std::string.
#define TEST_REL(A, REL, B)
Test a relation holds,e.g. TEST_REL(a,>,b);.
std::ostringstream tout
The debug printing stream.
#define TEST_EQUAL(a, b)
Test for equality of two things.
#define TEST_EQUAL_DOUBLE(a, b)
Test two doubles for near equality.
#define TEST(a)
Test a condition, without an additional explanation for failure.
Xapian-specific test helper functions and macros.
#define TEST_EXCEPTION(TYPE, CODE)
Check that CODE throws exactly Xapian exception TYPE.
Public interfaces for the Xapian library.