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";
170 "mset size = " << mset2.
size() <<
"\n";
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);
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.
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.
void init(const Xapian::Database &) override
Set this PostingSource to the start of the list of postings.
double get_weight() const override
Return the weight contribution for the current document.
This class is used to access a database, or a group of databases.
Xapian::doccount get_doccount() const
Get the number of documents in the database.
A handle representing a document in a Xapian database.
void add_boolean_term(const std::string &term)
Add a boolean filter term to the document.
void add_term(const std::string &tname, Xapian::termcount wdfinc=1)
Add a term to the document, without positional information.
void set_data(const std::string &data)
Set data stored in the document.
This class provides an interface to the information retrieval system for the purpose of searching.
void set_query(const Xapian::Query &query, Xapian::termcount qlen=0)
Set the query to run.
void set_cutoff(int percent_cutoff, double weight_cutoff=0)
Set the percentage and/or weight cutoffs.
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.
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.
void set_sort_by_value(Xapian::valueno sort_key, bool reverse)
Set the sorting to be by value only.
void set_weighting_scheme(const Weight &weight_)
Set the weighting scheme to use for queries.
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 any pending modifications made to the database.
Xapian::docid add_document(const Xapian::Document &document)
Add a new 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_sumpart(Xapian::termcount, Xapian::termcount, Xapian::termcount) const override
Calculate the weight contribution for this object's term to a document.
double get_sumextra(Xapian::termcount doclen, Xapian::termcount) const override
Calculate the term-independent weight component for 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.
int percent
The percentage score for a document in an MSet.
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.