48 : num_docs(num_docs_), last_docid(last_docid_), did(0)
53 : num_docs(db.get_doccount()), last_docid(db.get_lastdocid()), did(0)
56 PostingSource*
clone()
const override {
69 void next(
double wt)
override {
72 if (did % 2 == 0) ++did;
78 if (did % 2 == 0) ++did;
83 return did > last_docid;
148 : num_docs(num_docs_), last_docid(last_docid_), did(0)
155 : num_docs(db.get_doccount()), last_docid(db.get_lastdocid()), did(0)
158 PostingSource*
clone()
const override {
165 return (did % 2) ? 1000 : 0.001;
175 void next(
double wt)
override {
187 return did > last_docid;
193 return "MyOddWeightingPostingSource";
209 mset_expect_order(mset, 1, 3, 5, 7, 9, 11, 13, 15, 17, 2);
251 : num_docs(num_docs_), last_docid(last_docid_), did(0)
257 PostingSource*
clone()
const override {
268 FAIL_TEST(
"MyDontAskWeightPostingSource::get_weight() called");
278 void next(
double wt)
override {
290 return did > last_docid;
296 return "MyDontAskWeightPostingSource";
306 tout <<
"OP_SCALE_WEIGHT 0\n";
312 tout <<
"OP_FILTER\n";
321 tout <<
"BoolWeight\n";
342 tout <<
"OP_FILTER\n";
351 tout <<
"OP_FILTER other way\n";
460 : did(0), maxid_accessed(maxid_accessed_) { }
465 if (did > maxid_accessed) {
466 FAIL_TEST(
"ChangeMaxweightPostingSource::get_weight() called "
467 "for docid " +
str(did) +
", max id accessed "
468 "should be " +
str(maxid_accessed));
479 set_maxweight(5 - did);
484 set_maxweight(5 - did);
487 bool at_end()
const override {
return did >= 5; }
490 return "ChangeMaxweightPostingSource";
600 :
Xapian::DecreasingValueWeightPostingSource(0), count(count_) { }
606 void next(
double min_wt)
override {
616 for (
int wt = 20; wt > 0; --wt) {
627 #ifndef HAVE_TIMER_CREATE
628 SKIP_TEST(
"Enquire::set_time_limit() not implemented for this platform");
655 :
Xapian::DecreasingValueWeightPostingSource(0),
656 doclen_lb(doclen_lb_),
657 doclen_ub(doclen_ub_) { }
695 : clone_count(clone_count_)
698 PostingSource*
clone()
const override {
760 PostingSource*
clone()
const override {
766 if (shard_index == 0) {
777 return last_docid / 2;
782 void next(
double wt)
override {
785 if (did > last_docid) did = 0;
791 if (did > last_docid) did = 0;
801 return "OnlyTheFirstPostingSource";
842 : lb(lb_),
est(est_), ub(ub_)
845 PostingSource*
clone()
const override {
858 FAIL_TEST(
"EstimatePS::next() shouldn't be called");
862 FAIL_TEST(
"EstimatePS::skip_to() shouldn't be called");
870 FAIL_TEST(
"EstimatePS::get_docid() shouldn't be called");
882 {411, 424, 439, 420},
885 {411, 426, 439, 430},
886 {123, 351, 439, 400},
893 {411, 416, 439, 420},
894 {411, 412, 439, 420},
896 {111, 133, 138, 130},
897 {111, 137, 138, 130},
899 {411, 415, 419, 415},
DEFINE_TESTCASE(externalsource1, backend &&!remote &&!multi)
static void make_matchtimelimit1_db(Xapian::WritableDatabase &db, const string &)
static const testcase testcases[]
Xapian::Database get_database(const string &dbname)
test functionality of the Xapian API
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 next(double) override
Advance the current position to the next matching document.
void init(const Xapian::Database &) override
Set this PostingSource to the start of the list of postings.
bool at_end() const override
Return true if the current position is past the last entry in this list.
void skip_to(Xapian::docid to_did, double) override
Advance to the specified docid.
double get_weight() const override
Return the weight contribution for the current document.
Xapian::docid get_docid() const override
Return the current docid.
Xapian::doccount get_termfreq_min() const override
A lower bound on the number of documents this object can return.
string get_description() const override
Return a string describing this object.
ChangeMaxweightPostingSource(Xapian::docid maxid_accessed_)
Xapian::docid maxid_accessed
Xapian::doccount & doclen_ub
CheckBoundsPostingSource(Xapian::doccount &doclen_lb_, Xapian::doccount &doclen_ub_)
Xapian::doccount & doclen_lb
void init(const Xapian::Database &database) override
Set this PostingSource to the start of the list of postings.
CheckBoundsPostingSource * clone() const override
Clone the posting source.
Xapian::doccount get_termfreq_min() const override
A lower bound on the number of documents this object can return.
CloneTestPostingSource(int &clone_count_)
void init(const Xapian::Database &) override
Set this PostingSource to the start of the list of postings.
void skip_to(Xapian::docid, double) override
Advance to the specified docid.
string get_description() const override
Return a string describing this object.
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.
bool at_end() const override
Return true if the current position is past the last entry in this list.
Xapian::docid get_docid() const override
Return the current docid.
PostingSource * clone() const override
Clone the posting source.
PostingSource subclass for injecting tf bounds and estimate.
Xapian::doccount get_termfreq_max() const override
An upper bound on 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.
void skip_to(Xapian::docid, double) override
Advance to the specified docid.
EstimatePS(Xapian::doccount lb_, Xapian::doccount est_, Xapian::doccount ub_)
string get_description() const override
Return a string describing this object.
PostingSource * clone() const override
Clone the posting source.
void next(double) override
Advance the current position to the next matching document.
bool at_end() const override
Return true if the current position is past the last entry in this list.
Xapian::docid get_docid() const override
Return the current docid.
Xapian::doccount get_termfreq_min() const override
A lower 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.
Xapian::doccount get_termfreq_est() const override
An estimate of the number of documents this object can return.
PostingSource * clone() const override
Clone the posting source.
Xapian::doccount last_docid
Xapian::docid get_docid() const override
Return the current docid.
string get_description() const override
Return a string describing this object.
Xapian::doccount get_termfreq_max() const override
An upper bound on the number of documents this object can return.
Xapian::doccount get_termfreq_min() const override
A lower bound on the number of documents this object can return.
double get_weight() const override
Return the weight contribution for the current document.
void skip_to(Xapian::docid to_did, double wt) override
Advance to the specified docid.
void next(double wt) override
Advance the current position to the next matching document.
MyDontAskWeightPostingSource(Xapian::doccount num_docs_, Xapian::doccount last_docid_)
bool at_end() const override
Return true if the current position is past the last entry in this list.
void init(const Xapian::Database &db) override
Set this PostingSource to the start of the list of postings.
MyDontAskWeightPostingSource()
Xapian::doccount num_docs
string get_description() const override
Return a string describing this object.
void init(const Xapian::Database &) override
Set this PostingSource to the start of the list of postings.
void next(double wt) override
Advance the current position to the next matching document.
Xapian::doccount num_docs
MyOddPostingSource(const Xapian::Database &db)
Xapian::doccount get_termfreq_est() const override
An estimate of the number of documents this object can return.
Xapian::doccount last_docid
Xapian::doccount get_termfreq_max() const override
An upper bound on the number of documents this object can return.
void skip_to(Xapian::docid to_did, double wt) override
Advance to the specified docid.
PostingSource * clone() const override
Clone the posting source.
MyOddPostingSource(Xapian::doccount num_docs_, Xapian::doccount last_docid_)
Xapian::docid get_docid() const override
Return the current docid.
bool at_end() const override
Return true if the current position is past the last entry in this list.
Xapian::doccount get_termfreq_min() const override
A lower bound on 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.
Xapian::doccount get_termfreq_min() const override
A lower bound on the number of documents this object can return.
MyOddWeightingPostingSource(Xapian::doccount num_docs_, Xapian::doccount last_docid_)
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 next(double wt) override
Advance the current position to the next matching document.
void skip_to(Xapian::docid to_did, double wt) override
Advance to the specified docid.
PostingSource * clone() const override
Clone the posting source.
double get_weight() const override
Return the weight contribution for the current document.
void init(const Xapian::Database &) override
Set this PostingSource to the start of the list of postings.
MyOddWeightingPostingSource(const Xapian::Database &db)
Xapian::doccount num_docs
Xapian::doccount get_termfreq_est() const override
An estimate of the number of documents this object can return.
Xapian::doccount last_docid
Xapian::docid get_docid() const override
Return the current docid.
static Xapian::doccount shard_index
Xapian::docid get_docid() const override
Return the current docid.
OnlyTheFirstPostingSource(bool allow_clone_)
Xapian::doccount get_termfreq_min() const override
A lower bound on the number of documents this object can return.
void next(double wt) override
Advance the current position to the next matching document.
bool at_end() const override
Return true if the current position is past the last entry in this list.
string get_description() const override
Return a string describing this object.
Xapian::doccount get_termfreq_est() const override
An estimate of the number of documents this object can return.
void skip_to(Xapian::docid to_did, double wt) override
Advance to the specified docid.
PostingSource * clone() const override
Clone the posting source.
Xapian::doccount last_docid
Xapian::doccount get_termfreq_max() const override
An upper bound on the number of documents this object can return.
void init(const Xapian::Database &db) override
Set this PostingSource to the start of the list of postings.
SlowDecreasingValueWeightPostingSource * clone() const override
Clone the posting source.
SlowDecreasingValueWeightPostingSource(int &count_)
void next(double min_wt) override
Advance the current position to the next matching document.
Class implementing a "boolean" weighting scheme.
This class is used to access a database, or a group of databases.
Xapian::termcount get_doclength_lower_bound() const
Get a lower bound on the length of a document in this DB.
Xapian::doccount get_doccount() const
Get the number of documents in the database.
Xapian::docid get_lastdocid() const
Get the highest document id which has been used in the database.
Xapian::termcount get_doclength_upper_bound() const
Get an upper bound on the length of a document in this DB.
Read weights from a value which is known to decrease as docid increases.
void next(double min_wt)
Advance the current position to the next matching document.
void init(const Xapian::Database &db_)
Set this PostingSource to the start of the list of postings.
A handle representing a document in a Xapian database.
void add_value(Xapian::valueno slot, const std::string &value)
Add a new value.
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_time_limit(double time_limit)
Set a time limit for the match.
void set_cutoff(int percent_cutoff, double weight_cutoff=0)
Set the percentage and/or weight cutoffs.
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_docid_order(docid_order order)
Set sort order for document IDs.
void set_weighting_scheme(const Weight &weight_)
Set the weighting scheme to use for queries.
@ DESCENDING
docids sort in descending order.
A posting source which returns a fixed weight for all documents.
bool at_end() const
Return true if the current position is past the last entry in this list.
void init(const Database &db_)
Set this PostingSource to the start of the list of postings.
void next(double min_wt)
Advance the current position to the next matching document.
Xapian::docid get_docid() const
Return the current docid.
void skip_to(Xapian::docid min_docid, double min_wt)
Advance to the specified docid.
bool check(Xapian::docid min_docid, double min_wt)
Check if the specified docid occurs.
InvalidArgumentError indicates an invalid parameter value was passed to the API.
InvalidOperationError indicates the API was used in an invalid way.
Iterator over a Xapian::MSet.
Class representing a list of search results.
Xapian::doccount size() const
Return number of items in this MSet object.
double get_max_possible() const
The maximum possible weight any document could achieve.
bool empty() const
Return true if this MSet object is empty.
std::string get_description() const
Return a string describing this object.
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.
Xapian::doccount get_matches_estimated() const
Estimate of the total number of matching documents.
Base class which provides an "external" source of postings.
double get_maxweight() const
Return the currently set upper bound on what get_weight() can return.
PostingSource * release()
Start reference counting this object.
Class representing a query.
@ OP_SCALE_WEIGHT
Scale the weight contributed by a subquery.
@ OP_AND_MAYBE
Match the first subquery taking extra weight from other subqueries.
@ 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.
UnimplementedError indicates an attempt to use an unimplemented feature.
void skip_to(Xapian::docid min_docid, double min_wt)
Advance to the specified docid.
Xapian::doccount get_termfreq_est() const
An estimate of the number of documents this object can return.
Xapian::doccount get_termfreq_max() const
An upper bound on the number of documents this object can return.
bool at_end() const
Return true if the current position is past the last entry in this list.
Xapian::doccount get_termfreq_min() const
A lower bound on the number of documents this object can return.
Xapian::docid get_docid() const
Return the current docid.
A posting source which reads weights from a value slot.
void init(const Database &db_)
Set this PostingSource to the start of the list of postings.
This class provides read/write access to a database.
Xapian::docid add_document(const Xapian::Document &document)
Add a new document to the database.
void sleep(double t)
Sleep until the time represented by this object.
string str(int value)
Convert int to std::string.
The Xapian namespace contains public interfaces for the Xapian library.
std::string sortable_serialise(double value)
Convert a floating point number to a string, preserving sort order.
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
static double est(double l, double r, double n)
<unistd.h>, but with compat.
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 FAIL_TEST(MSG)
Fail the current testcase with message MSG.
#define SKIP_TEST(MSG)
Skip the current testcase with message MSG.
#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.
void mset_expect_order(const Xapian::MSet &A, Xapian::docid d1, Xapian::docid d2, Xapian::docid d3, Xapian::docid d4, Xapian::docid d5, Xapian::docid d6, Xapian::docid d7, Xapian::docid d8, Xapian::docid d9, Xapian::docid d10, Xapian::docid d11, Xapian::docid d12)
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.