67 j = i.positionlist_begin();
90 j = i.positionlist_begin();
132 i = doc.termlist_begin();
137 j = i.positionlist_begin();
146 k = doc.values_begin();
160 j = i.positionlist_begin();
189 TEST_EQUAL(q.get_description(),
"Query(hello)");
195 TEST_EQUAL(q.get_description(),
"Query(hello@1)");
200 TEST_EQUAL(q.get_description(),
"Query((hello OR world))");
207 TEST_EQUAL(q.get_description(),
"Query((hello@1 OR world@1))");
209 static const char *
const phrase[] = {
"shaken",
"not",
"stirred" };
226 s2.set_default_weight(5.0);
249 s2.set_default_weight(5.0);
266 :
Xapian::ValuePostingSource(0), desc(desc_)
274 std::string
name()
const override {
275 return "MyPostingSource2";
289 return "MyPostingSource2(" + desc +
")";
333 return "ExceptionalPostingSource";
336 PostingSource*
clone()
const override {
352 bool at_end()
const override {
return true; }
369 FAIL_TEST(
"Expected bad_alloc exception to be thrown");
370 }
catch (
const bad_alloc &) {
391 return "ExceptionalWeight";
427 FAIL_TEST(
"Expected bad_alloc exception to be thrown");
428 }
catch (
const bad_alloc &) {
449 return "ExceptionalMatchSpy";
473 FAIL_TEST(
"Expected bad_alloc exception to be thrown");
474 }
catch (
const bad_alloc &) {
The Xapian namespace contains public interfaces for the Xapian library.
Xapian::Document get_document(Xapian::docid did) const
Get a document from the database, given its document id.
Xapian::docid add_document(const Xapian::Document &document)
Add a new document to the database.
void register_weighting_scheme(const Xapian::Weight &wt)
Register a weighting scheme.
void add_value(Xapian::valueno slot, const std::string &value)
Add a new value.
static const Query unserialise(const std::string &serialised, const Registry ®=Registry())
Unserialise a string and return a Query object.
void init(double) override
Allow the subclass to perform any initialisation it needs to.
double get_weight() const override
Return the weight contribution for the current document.
MatchSpy * clone() const override
Clone the match spy.
std::string name() const override
Name of the posting source class.
This class is used to access a database, or a group of databases.
Xapian::termcount termlist_count() const
The length of the termlist - i.e.
virtual std::string name() const
Return the name of this weighting scheme.
Abstract base class for match spies.
A posting source which looks up weights in a map using values as the key.
Xapian::docid get_docid() const override
Return the current docid.
ValueIterator values_begin() const
Iterator for the values in this document.
virtual PostingSource * unserialise(const std::string &serialised) const
Create object given string serialisation returned by serialise().
Class for iterating over document values.
const Xapian::PostingSource * get_posting_source(const std::string &name) const
Get a posting source given a name.
ExceptionalWeight(failmode fail_)
MyPostingSource2(const std::string &desc_)
string name() const override
Return the name of this weighting scheme.
ExceptionalPostingSource(failmode fail_)
TermIterator termlist_end() const
Equivalent end iterator for termlist_begin().
std::string serialise() const
Serialise document into a string.
Xapian::doccount get_termfreq_est() const override
An estimate of the number of documents this object can return.
test functionality of the Xapian API
Class for iterating over a list of terms.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
Xapian::doccount get_termfreq_max() const override
An upper bound on the number of documents this object can return.
#define TEST_NOT_EQUAL(a, b)
Test for non-equality of two things.
const Xapian::MatchSpy * get_match_spy(const std::string &name) const
Get a match spy given a name.
DEFINE_TESTCASE(serialise_document1, !backend)
This class provides read/write access to a database.
Indicates an error in the std::string serialisation of an object.
void register_match_spy(const Xapian::MatchSpy &spy)
Register a user-defined match spy class.
void skip_to(Xapian::docid, double) override
Advance to the specified docid.
Registry for user subclasses.
string name() const override
Name of the posting source class.
Public interfaces for the Xapian library.
MyPostingSource2 * clone() const override
Clone the posting source.
double get_sumextra(Xapian::termcount, Xapian::termcount) const override
Calculate the term-independent weight component for a document.
A posting source which returns a fixed weight for all documents.
const Xapian::Weight * get_weighting_scheme(const std::string &name) const
Get the weighting scheme given a name.
#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.
Xapian::termcount values_count() const
Count the values in this document.
std::string serialise() const
Serialise this object into a string.
Class for iterating over term positions.
void next(double) override
Advance the current position to the next matching document.
Base class which provides an "external" source of postings.
bool at_end() const override
Return true if the current position is past the last entry in this list.
ValueIterator values_end() const
Equivalent end iterator for values_begin().
std::string serialise() const override
Serialise object parameters into a string.
A posting source which generates weights from a value slot.
double get_sumpart(Xapian::termcount, Xapian::termcount, Xapian::termcount) const override
Calculate the weight contribution for this object's term to a document.
std::string get_description() const override
Return a string describing this object.
void add_posting(const std::string &tname, Xapian::termpos tpos, Xapian::termcount wdfinc=1)
Add an occurrence of a term at a particular position.
A posting source which reads weights from a value slot.
#define FAIL_TEST(MSG)
Fail the current testcase with message MSG.
static Document unserialise(const std::string &serialised)
Unserialise a document from a string produced by serialise().
Xapian::Database get_database(const string &dbname)
void register_posting_source(const Xapian::PostingSource &source)
Register a user-defined posting source class.
std::string get_description() const
Return a string describing this object.
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
void operator()(const Xapian::Document &, double) override
Register a document with the match spy.
Xapian::doccount get_termfreq_min() const override
A lower bound on the number of documents this object can return.
MyPostingSource2 * unserialise(const std::string &s) const override
Create object given string serialisation returned by serialise().
Weight * clone() const override
Clone this object.
Xapian-specific test helper functions and macros.
virtual std::string serialise() const
Serialise object parameters into a string.
double get_maxextra() const override
Return an upper bound on what get_sumextra() can return for any document.
void init(const Xapian::Database &) override
Set this PostingSource to the start of the list of postings.
PostingSource * clone() const override
Clone the posting source.
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
Class representing a query.
std::string get_data() const
Get data stored in the document.
#define TEST_EQUAL(a, b)
Test for equality of two things.
ExceptionalMatchSpy(failmode fail_)
void set_data(const std::string &data)
Set data stored in the document.
TermIterator termlist_begin() const
Start iterating the terms in this document.
string name() const override
Return the name of this match spy.
virtual std::string name() const
Name of the posting source class.
A handle representing a document in a Xapian database.
Xapian::Weight subclass implementing the BM25 probabilistic formula.
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.
virtual std::string name() const
Return the name of this match spy.