132 i = doc.termlist_begin();
146 k = doc.values_begin();
209 static const char *
const phrase[] = {
"shaken",
"not",
"stirred" };
266 :
Xapian::ValuePostingSource(0), desc(desc_)
274 std::string
name()
const override {
275 return "MyPostingSource2";
289 return "MyPostingSource2(" + desc +
")";
326 typedef enum {
NONE, CLONE } failmode;
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 &) {
384 typedef enum {
NONE, CLONE } failmode;
391 return "exceptional";
422 FAIL_TEST(
"Expected bad_alloc exception to be thrown");
423 }
catch (
const bad_alloc &) {
437 typedef enum {
NONE, CLONE } failmode;
444 return "ExceptionalMatchSpy";
468 FAIL_TEST(
"Expected bad_alloc exception to be thrown");
469 }
catch (
const bad_alloc &) {
DEFINE_TESTCASE(serialise_document1, !backend)
Xapian::Database get_database(const string &dbname)
test functionality of the Xapian API
void operator()(const Xapian::Document &, double) override
Register a document with the match spy.
string name() const override
Return the name of this match spy.
MatchSpy * clone() const override
Clone the match spy.
ExceptionalMatchSpy(failmode fail_)
PostingSource * clone() const override
Clone the posting source.
string name() const override
Name of the posting source class.
bool at_end() const override
Return true if the current position is past the last entry in this list.
Xapian::doccount get_termfreq_est() const override
An estimate of the number of documents this object can return.
ExceptionalPostingSource(failmode fail_)
Xapian::doccount get_termfreq_min() const override
A lower bound on the number of documents this object can return.
Xapian::docid get_docid() const override
Return the current 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, double) override
Advance to the specified docid.
void reset(const Xapian::Database &, Xapian::doccount) override
Set this PostingSource to the start of the list of postings.
void next(double) override
Advance the current position to the next matching document.
Weight * clone() const override
Clone this object.
ExceptionalWeight(failmode fail_)
double get_sumpart(Xapian::termcount, Xapian::termcount, Xapian::termcount, Xapian::termcount) const override
Calculate the weight contribution for this object's term to a document.
void init(double) override
Allow the subclass to perform any initialisation it needs to.
double get_maxpart() const override
Return an upper bound on what get_sumpart() can return for any document.
string name() const override
Return the name of this weighting scheme, e.g.
MyPostingSource2 * unserialise(const std::string &s) const override
Create object given string serialisation returned by serialise().
std::string serialise() const override
Serialise object parameters into a string.
MyPostingSource2(const std::string &desc_)
std::string get_description() const override
Return a string describing this object.
double get_weight() const override
Return the weight contribution for the current document.
MyPostingSource2 * clone() const override
Clone the posting source.
std::string name() const override
Name of the posting source class.
Xapian::Weight subclass implementing the BM25 probabilistic formula.
An indexed database of documents.
Xapian::Document get_document(Xapian::docid did, unsigned flags=0) const
Get a document from the database.
Class representing a document.
void set_data(std::string_view data)
Set the document data.
std::string get_data() const
Get the document data.
void add_term(std::string_view term, Xapian::termcount wdf_inc=1)
Add a term to this document.
Xapian::valueno values_count() const
Count the value slots used in this document.
ValueIterator values_begin() const
Start iterating the values in this document.
std::string serialise() const
Serialise document into a string.
TermIterator termlist_end() const noexcept
End iterator corresponding to termlist_begin().
Xapian::termcount termlist_count() const
Return the number of distinct terms in this document.
TermIterator termlist_begin() const
Start iterating the terms in this document.
ValueIterator values_end() const noexcept
End iterator corresponding to values_begin().
static Document unserialise(std::string_view serialised)
Unserialise a document from a string produced by serialise().
void add_value(Xapian::valueno slot, std::string_view value)
Add a value to a slot in this document.
void add_posting(std::string_view term, Xapian::termpos term_pos, Xapian::termcount wdf_inc=1)
Add a posting for a term.
A posting source which returns a fixed weight for all documents.
Abstract base class for match spies.
Class for iterating over term positions.
Base class which provides an "external" source of postings.
virtual PostingSource * unserialise(const std::string &serialised) const
Create object given string serialisation returned by serialise().
virtual std::string serialise() const
Serialise object parameters into a string.
Class representing a query.
std::string get_description() const
Return a string describing this object.
static const Query unserialise(std::string_view serialised, const Registry ®=Registry())
Unserialise a string and return a Query object.
@ OP_SCALE_WEIGHT
Scale the weight contributed by a subquery.
@ OP_OR
Match documents which at least one subquery matches.
@ OP_PHRASE
Match only documents where all subqueries match near and in order.
std::string serialise() const
Serialise this object into a string.
Registry for user subclasses.
const Xapian::PostingSource * get_posting_source(std::string_view name) const
Get a posting source given a name.
const Xapian::MatchSpy * get_match_spy(std::string_view name) const
Get a match spy given a name.
void register_posting_source(const Xapian::PostingSource &source)
Register a user-defined posting source class.
const Xapian::Weight * get_weighting_scheme(std::string_view name) const
Get the weighting scheme given a name.
void register_weighting_scheme(const Xapian::Weight &wt)
Register a weighting scheme.
void register_match_spy(const Xapian::MatchSpy &spy)
Register a user-defined match spy class.
Indicates an error in the std::string serialisation of an object.
Class for iterating over a list of terms.
PositionIterator positionlist_end() const noexcept
Return an end PositionIterator for the current term.
Xapian::termcount positionlist_count() const
Return the length of the position list for the current position.
Xapian::termcount get_wdf() const
Return the wdf for the term at the current position.
PositionIterator positionlist_begin() const
Return a PositionIterator for the current term.
UnimplementedError indicates an attempt to use an unimplemented feature.
Class for iterating over document values.
Xapian::valueno get_valueno() const
Return the value slot number for the current position.
A posting source which looks up weights in a map using values as the key.
void set_default_weight(double wt)
Set a default weight for document values not in the map.
A posting source which generates weights from a value slot.
A posting source which reads weights from a value slot.
Abstract base class for weighting schemes.
This class provides read/write access to a database.
Xapian::docid add_document(const Xapian::Document &doc)
Add a document to the database.
The Xapian namespace contains public interfaces for the Xapian library.
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.
#define FAIL_TEST(MSG)
Fail the current testcase with message MSG.
#define TEST_EQUAL(a, b)
Test for equality of two things.
#define TEST_NOT_EQUAL(a, b)
Test for non-equality of two things.
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.