48 tout << *bigmset[start] <<
":" << bigmset[start].get_weight() <<
":" 49 << bigmset[start].get_percent() <<
"%\n";
54 min(start + size, bigmset.
size()));
61 bigmset[start + i].get_weight());
63 bigmset[start + i].get_percent());
70 vector<pair<Xapian::docid, double>>
weights;
71 vector<pair<Xapian::docid, double>>::const_iterator
i;
76 : weights(weights_), started(
false)
78 set_maxweight(max_wt);
84 PostingSource*
clone()
const override {
89 weights.push_back(make_pair(did, wt));
90 if (wt > get_maxweight()) set_maxweight(wt);
98 return weights.size();
101 return weights.size();
104 return weights.size();
117 return (i == weights.end());
123 return "MyPostingSource";
141 if (mset[1].get_percent() != 50)
break;
165 tout <<
"mset1 item = " << i.get_percent() <<
"%\n";
166 if (new_percent != percent) {
169 tout <<
"cutoff = " << percent <<
"%, " 170 "mset size = " << mset2.
size() <<
"\n";
172 percent = new_percent;
204 static const char *
const terms[] = {
"paragraph",
"banana" };
210 for (i = mset.
begin(); i != mset.
end(); ++i) {
243 TEST(mset[0].get_percent() < 100);
247 TEST_REL(mset[0].get_percent(), >=, 50);
253 TEST(mset[0].get_percent() < 100);
254 TEST_REL(mset[0].get_percent(), >=, 50);
266 TEST(mset[0].get_percent() < 100);
272 TEST_EQUAL(mset[0].get_percent(), mset2[0].get_percent());
278 for (
int i = 1; i <= 6; ++i) {
281 d.
add_term(
"boom", 2 + (i - 4)*(i - 2));
342 static const char *
const terms[] = {
"this",
"spoken",
"blank" };
348 TEST(mset[0].get_percent() != 100);
350 TEST_REL(mset[0].get_percent(), >, 1);
Xapian::doccount size() const
Return number of items in this MSet object.
Xapian::docid add_document(const Xapian::Document &document)
Add a new document to the database.
void set_sort_by_value_then_relevance(Xapian::valueno sort_key, bool reverse)
Set the sorting to be by value, then by relevance for documents with the same value.
#define TEST(a)
Test a condition, without an additional explanation for failure.
double get_maxextra() const override
Return an upper bound on what get_sumextra() can return for any document.
int convert_to_percent(double weight) const
Convert a weight to a percentage.
This class is used to access a database, or a group of databases.
double get_weight() const override
Return the weight contribution for the current document.
void set_sort_by_value(Xapian::valueno sort_key, bool reverse)
Set the sorting to be by value only.
Xapian::doccount get_termfreq_min() const override
A lower bound on the number of documents this object can return.
Weight * clone() const override
Clone this object.
Match documents which an odd number of subqueries match.
void set_cutoff(int percent_cutoff, double weight_cutoff=0)
Set the percentage and/or weight cutoffs.
bool empty() const
Return true if this MSet object is empty.
double get_sumpart(Xapian::termcount, Xapian::termcount, Xapian::termcount) const override
Calculate the weight contribution for this object's term to a document.
Class representing a list of search results.
MSet get_mset(Xapian::doccount first, Xapian::doccount maxitems, Xapian::doccount checkatleast=0, const RSet *omrset=0, const MatchDecider *mdecider=0) const
Get (a portion of) the match set for the current query.
Convert types to std::string.
Xapian::doccount get_doccount() const
Get the number of documents in the database.
Xapian::docid get_docid() const override
Return the current docid.
PostingSource * clone() const override
Clone the posting source.
static void make_topercent7_db(Xapian::WritableDatabase &db, const string &)
test functionality of the Xapian API
double get_sumextra(Xapian::termcount doclen, Xapian::termcount) const override
Calculate the term-independent weight component for a document.
void init(const Xapian::Database &) override
Set this PostingSource to the start of the list of postings.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
#define TEST_REL(A, REL, B)
Test a relation holds,e.g. TEST_REL(a,>,b);.
This class provides read/write access to a database.
std::ostringstream tout
The debug printing stream.
Iterator over a Xapian::MSet.
void init(double) override
Allow the subclass to perform any initialisation it needs to.
Public interfaces for the Xapian library.
Match like OP_AND but only taking weight from the first subquery.
#define TEST_EXCEPTION(TYPE, CODE)
Check that CODE throws exactly Xapian exception TYPE.
double get_maxpart() const override
Return an upper bound on what get_sumpart() can return for any document.
vector< pair< Xapian::docid, double > > weights
string str(int value)
Convert int to std::string.
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.
int percent
The percentage score for a document in an MSet.
void commit()
Commit any pending modifications made to the database.
Xapian::Weight subclass implementing the traditional probabilistic formula.
Base class which provides an "external" source of postings.
void append_docweight(Xapian::docid did, double wt)
int get_percent() const
Convert the weight of the current iterator position to a percentage.
#define TEST_EQUAL_DOUBLE(a, b)
Test two doubles for near equality.
Xapian::doccount get_termfreq_est() const override
An estimate of the number of documents this object can return.
Xapian::doccount get_termfreq_max() const override
An upper bound on the number of documents this object can return.
void set_query(const Xapian::Query &query, Xapian::termcount qlen=0)
Set the query to run.
vector< pair< Xapian::docid, double > >::const_iterator i
bool at_end() const override
Return true if the current position is past the last entry in this list.
Match only documents which all subqueries match.
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())
DEFINE_TESTCASE(consistency3, backend)
Xapian::Database get_database(const string &dbname)
This class provides an interface to the information retrieval system for the purpose of searching...
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
Match documents which at least one subquery matches.
Xapian-specific test helper functions and macros.
void add_boolean_term(const std::string &term)
Add a boolean filter term to the document.
MyPostingSource(const vector< pair< Xapian::docid, double >> &weights_, double max_wt)
void set_weighting_scheme(const Weight &weight_)
Set the weighting scheme to use for queries.
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
Class representing a query.
#define TEST_EQUAL(a, b)
Test for equality of two things.
void set_data(const std::string &data)
Set data stored in the document.
void next(double) override
Advance the current position to the next matching document.
A handle representing a document in a Xapian database.
string get_description() const override
Return a string describing this object.
UnimplementedError indicates an attempt to use an unimplemented feature.
void add_term(const std::string &tname, Xapian::termcount wdfinc=1)
Add a term to the document, without positional information.
Abstract base class for weighting schemes.