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_)
276 return "MyPostingSource2";
290 return "MyPostingSource2(" + desc +
")";
334 return "ExceptionalPostingSource";
370 FAIL_TEST(
"Expected bad_alloc exception to be thrown");
371 }
catch (
const bad_alloc &) {
392 return "ExceptionalWeight";
423 FAIL_TEST(
"Expected bad_alloc exception to be thrown");
424 }
catch (
const bad_alloc &) {
445 return "ExceptionalMatchSpy";
469 FAIL_TEST(
"Expected bad_alloc exception to be thrown");
470 }
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.
double get_sumextra(Xapian::termcount, Xapian::termcount) const
Calculate the term-independent weight component for a document.
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.
MyPostingSource2 * unserialise(const std::string &s) const
Create object given string serialisation returned by serialise().
string name() const
Name of the posting source class.
void next(double)
Advance the current position to the next matching document.
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.
bool at_end() const
Return true if the current position is past the last entry in this list.
A posting source which looks up weights in a map using values as the key.
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().
std::string name() const
Name of the posting source class.
Class for iterating over document values.
void operator()(const Xapian::Document &, double)
Register a document with the match spy.
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_)
ExceptionalPostingSource(failmode fail_)
double get_weight() const
Return the weight contribution for the current document.
TermIterator termlist_end() const
Equivalent end iterator for termlist_begin().
std::string serialise() const
Serialise document into a string.
void skip_to(Xapian::docid, double)
Advance to the specified docid.
PostingSource * clone() const
Clone the posting source.
MyPostingSource2 * clone() const
Clone the posting source.
test functionality of the Xapian API
Class for iterating over a list of terms.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
#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.
Weight * clone() const
Clone this object.
DEFINE_TESTCASE(serialise_document1, !backend)
MatchSpy * clone() const
Clone the match spy.
This class provides read/write access to a database.
Indicates an error in the std::string serialisation of an object.
void init(const Xapian::Database &)
Set this PostingSource to the start of the list of postings.
void register_match_spy(const Xapian::MatchSpy &spy)
Register a user-defined match spy class.
Registry for user subclasses.
Public interfaces for the Xapian library.
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.
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.
string name() const
Return the name of this match spy.
Xapian::doccount get_termfreq_min() const
A lower bound on the number of documents this object can return.
Base class which provides an "external" source of postings.
string name() const
Return the name of this weighting scheme.
ValueIterator values_end() const
Equivalent end iterator for values_begin().
double get_sumpart(Xapian::termcount, Xapian::termcount, Xapian::termcount) const
Calculate the weight contribution for this object's term to a document.
A posting source which generates weights from a value slot.
void init(double)
Allow the subclass to perform any initialisation it needs to.
void add_posting(const std::string &tname, Xapian::termpos tpos, Xapian::termcount wdfinc=1)
Add an occurrence of a term at a particular position.
std::string serialise() const
Serialise object parameters into a string.
std::string get_description() const
Return a string describing this object.
double get_maxpart() const
Return an upper bound on what get_sumpart() can return for any document.
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.
double get_maxextra() const
Return an upper bound on what get_sumextra() can return for any document.
std::string get_description() const
Return a string describing this object.
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
Xapian-specific test helper functions and macros.
virtual std::string serialise() const
Serialise object parameters into a string.
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.
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.
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.
Xapian::docid get_docid() const
Return the current docid.
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.