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);
90 weights.push_back(make_pair(did, wt));
91 if (wt > get_maxweight()) set_maxweight(wt);
112 return (i == weights.end());
118 return "MyPostingSource";
136 if (mset[1].get_percent() != 50)
break;
160 tout <<
"mset1 item = " << i.get_percent() <<
"%\n";
161 if (new_percent != percent) {
164 tout <<
"cutoff = " << percent <<
"%, " 165 "mset size = " << mset2.
size() <<
"\n";
167 percent = new_percent;
199 static const char *
const terms[] = {
"paragraph",
"banana" };
205 for (i = mset.
begin(); i != mset.
end(); ++i) {
238 TEST(mset[0].get_percent() < 100);
242 TEST_REL(mset[0].get_percent(), >=, 50);
254 TEST(mset[0].get_percent() < 100);
260 TEST_EQUAL(mset[0].get_percent(), mset2[0].get_percent());
266 for (
int i = 1; i <= 6; ++i) {
269 d.
add_term(
"boom", 2 + (i - 4)*(i - 2));
330 static const char *
const terms[] = {
"this",
"spoken",
"blank" };
336 TEST(mset[0].get_percent() != 100);
338 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.
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_maxpart() const
Return an upper bound on what get_sumpart() can return for any document.
void set_sort_by_value(Xapian::valueno sort_key, bool reverse)
Set the sorting to be by value only.
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.
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.
void next(double)
Advance the current position to the next matching document.
Xapian::doccount get_doccount() const
Get the number of documents in the database.
Xapian::doccount get_termfreq_min() const
A lower bound on the number of documents this object can return.
static void make_topercent7_db(Xapian::WritableDatabase &db, const string &)
test functionality of the Xapian API
PostingSource * clone() const
Clone the posting source.
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);.
Weight * clone() const
Clone this object.
Xapian::doccount get_termfreq_est() const
An estimate of the number of documents this object can return.
double get_sumextra(Xapian::termcount doclen, Xapian::termcount) const
Calculate the term-independent weight component for a document.
This class provides read/write access to a database.
std::ostringstream tout
The debug printing stream.
Iterator over a Xapian::MSet.
Public interfaces for the Xapian library.
void init(const Xapian::Database &)
Set this PostingSource to the start of the list of postings.
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.
vector< pair< Xapian::docid, double > > weights
bool at_end() const
Return true if the current position is past the last entry in this list.
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.
double get_sumpart(Xapian::termcount, Xapian::termcount, Xapian::termcount) const
Calculate the weight contribution for this object's term to a document.
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.
void set_query(const Xapian::Query &query, Xapian::termcount qlen=0)
Set the query to run.
string get_description() const
Return a string describing this object.
vector< pair< Xapian::docid, double > >::const_iterator i
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.
Xapian::doccount get_termfreq_max() const
An upper bound on the number of documents this object can return.
Match documents which at least one subquery matches.
Xapian-specific test helper functions and macros.
double get_maxextra() const
Return an upper bound on what get_sumextra() can return for any document.
void init(double)
Allow the subclass to perform any initialisation it needs to.
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.
double get_weight() const
Return the weight contribution for the current document.
A handle representing a document in a Xapian database.
Xapian::docid get_docid() const
Return the current docid.
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.