27 #define XAPIAN_DEPRECATED(D) D
190 #define singlesubquery1_(OP) \
191 TEST_STRINGS_EQUAL(Xapian::Query(q->OP, q, q + 1).get_description(),\
209 #define singlesubquery2_(OP) \
210 TEST_STRINGS_EQUAL(Xapian::Query(q->OP, q, q + 1).get_description(),\
228 #define singlesubquery3_(OP) \
229 TEST_STRINGS_EQUAL(Xapian::Query(q->OP, q, q + 1).get_description(),\
230 "Query(<alldocuments>)")
272 :
Xapian::RangeProcessor(0), destroyed(destroyed_) { }
281 bool gone_auto, gone;
362 bool gone_auto, gone;
426 bool gone_auto, gone;
483 bool operator()(
const std::string&)
const override {
return true; }
488 bool gone_auto, gone;
558 bool gone_auto, gone;
641 bool gone_auto, gone;
715 bool operator()(
const string&)
const override {
return true; }
725 bool gone_auto, gone;
734 (void)enq.
get_eset(5, rset, 0, &edecider_auto);
743 (void)enq.
get_eset(5, rset, 0, edecider);
777 edecider->
release()))->release());
790 &edecider_auto))->release());
810 bool gone_auto, gone;
882 doc.
set_data(
"\xc0\x80\xf5\x80\x80\x80\xfe\xff");
884 "Document(data='\\xc0\\x80\\xf5\\x80\\x80\\x80\\xfe\\xff')");
885 doc.
set_data(
string(
"\x00\x1f", 2));
887 "Document(data='\\x00\\x1f')");
891 "Document(data='back\\x5cslash')");
901 for (
bool preinc : {
false,
true }) {
905 indexer.
index_text(
"Pull the rug out from under ourselves", 1,
"S");
909 const string& term = *term_iterator;
913 if (preinc) ++term_iterator;
915 if (!preinc) ++term_iterator;
930 auto new_pos = prev_pos + pos;
980 static const Xapian::termpos expected[] = { 5, 8, 13, 21, 377, 610, 9999 };
1004 FAIL_TEST(
"Expected exception to be thrown");
DEFINE_TESTCASE(version1, !backend)
#define singlesubquery1_(OP)
#define singlesubquery3_(OP)
#define singlesubquery2_(OP)
static void errorcopyctor_helper(Xapian::Error &error)
Xapian::Database get_database(const string &dbname)
test functionality of the Xapian API
DestroyedFlag(bool &destroyed_)
TestExpandDecider(bool &destroyed_)
bool operator()(const string &) const override
Do we want this term in the ESet?
TestFieldProcessor(bool &destroyed_)
Xapian::Query operator()(const string &str) override
Convert a field-prefixed string to a Query object.
string operator()(const Xapian::Document &) const override
Build a key string for a Document.
TestKeyMaker(bool &destroyed_)
void operator()(const Xapian::Document &, double) override
Register a document with the match spy.
TestMatchSpy(bool &destroyed_)
Xapian::Query operator()(const std::string &, const std::string &) override
Check for a valid range of this type.
TestRangeProcessor(bool &destroyed_)
bool operator()(const std::string &) const override
Is term a stop-word?
TestStopper(bool &destroyed_)
Xapian::valueno operator()(std::string &, std::string &)
Check for a valid range of this type.
TestValueRangeProcessor(bool &destroyed_)
This class is used to access a database, or a group of databases.
std::string get_metadata(const std::string &key) const
Get the user-specified metadata associated with a given key.
ValueIterator valuestream_begin(Xapian::valueno slot) const
Return an iterator over the value in slot slot for each document.
ValueIterator valuestream_end(Xapian::valueno) const
Return end iterator corresponding to valuestream_begin().
Xapian::TermIterator metadata_keys_end(const std::string &=std::string()) const
Corresponding end iterator to metadata_keys_begin().
TermIterator termlist_begin(Xapian::docid did) const
An iterator pointing to the start of the termlist for a given document.
Xapian::TermIterator metadata_keys_begin(const std::string &prefix=std::string()) const
An iterator which returns all user-specified metadata keys.
Xapian::termcount get_doclength(Xapian::docid did) const
Get the length of a document.
TermIterator allterms_begin(const std::string &prefix=std::string()) const
An iterator which runs across all terms with a given prefix.
TermIterator allterms_end(const std::string &=std::string()) const
Corresponding end iterator to allterms_begin(prefix).
Xapian::Document get_document(Xapian::docid did) const
Get a document from the database, given its document id.
Xapian::docid get_lastdocid() const
Get the highest document id which has been used in the database.
PositionIterator positionlist_begin(Xapian::docid did, const std::string &tname) const
An iterator pointing to the start of the position list for a given term in a given document.
Xapian::termcount get_unique_terms(Xapian::docid did) const
Get the number of unique terms in document.
A handle representing a document in a Xapian database.
void remove_term(const std::string &tname)
Remove a term and all postings associated with it.
void remove_posting(const std::string &tname, Xapian::termpos tpos, Xapian::termcount wdfdec=1)
Remove a posting of a term from the document.
void add_value(Xapian::valueno slot, const std::string &value)
Add a new value.
void add_posting(const std::string &tname, Xapian::termpos tpos, Xapian::termcount wdfinc=1)
Add an occurrence of a term at a particular position.
Xapian::termpos remove_postings(const std::string &term, Xapian::termpos term_pos_first, Xapian::termpos term_pos_last, Xapian::termcount wdf_dec=1)
Remove a range of postings for a term.
ValueIterator values_begin() const
Iterator for the values in this document.
docid get_docid() const
Get the document id which is associated with this document (if any).
void add_boolean_term(const std::string &term)
Add a boolean filter term to the document.
TermIterator termlist_end() const
Equivalent end iterator for termlist_begin().
ValueIterator values_end() const
Equivalent end iterator for values_begin().
void add_term(const std::string &tname, Xapian::termcount wdfinc=1)
Add a term to the document, without positional information.
Xapian::termcount termlist_count() const
The length of the termlist - i.e.
TermIterator termlist_begin() const
Start iterating the terms in this document.
void clear_values()
Remove all values associated with the document.
std::string get_description() const
Return a string describing this object.
void clear_terms()
Remove all terms (and postings) from the document.
void set_data(const std::string &data)
Set data stored in the document.
Xapian::termcount values_count() const
Count the values in this document.
This class provides an interface to the information retrieval system for the purpose of searching.
void set_sort_by_key(Xapian::KeyMaker *sorter, bool reverse)
Set the sorting to be by key generated from values only.
void add_matchspy(MatchSpy *spy)
Add a matchspy.
ESet get_eset(Xapian::termcount maxitems, const RSet &omrset, int flags=0, const Xapian::ExpandDecider *edecider=0, double min_wt=0.0) const
Get the expand set for the given rset.
void set_sort_by_key_then_relevance(Xapian::KeyMaker *sorter, bool reverse)
Set the sorting to be by keys generated from values, then by relevance for documents with identical k...
void set_sort_by_relevance_then_key(Xapian::KeyMaker *sorter, bool reverse)
Set the sorting to be by relevance, then by keys generated from values.
static const int INCLUDE_QUERY_TERMS
Terms in the query may be returned by get_eset().
All exceptions thrown by Xapian are subclasses of Xapian::Error.
ExpandDecider subclass which rejects terms using two ExpandDeciders.
Virtual base class for expand decider functor.
ExpandDecider * release()
Start reference counting this object.
Base class for field processors.
FieldProcessor * release()
Start reference counting this object.
InvalidArgumentError indicates an invalid parameter value was passed to the API.
InvalidOperationError indicates the API was used in an invalid way.
Virtual base class for key making functors.
KeyMaker * release()
Start reference counting this object.
Abstract base class for match spies.
MatchSpy * release()
Start reference counting this object.
Build a Xapian::Query object from a user query string.
void add_rangeprocessor(Xapian::RangeProcessor *range_proc, const std::string *grouping=NULL)
Register a RangeProcessor.
void add_valuerangeprocessor(Xapian::ValueRangeProcessor *vrproc)
Register a ValueRangeProcessor.
void set_stopper(const Stopper *stop=NULL)
Set the stopper.
void add_prefix(const std::string &field, const std::string &prefix)
Add a free-text field term prefix.
Class representing a query.
bool empty() const
Check if this query is Xapian::Query::MatchNothing.
std::string get_description() const
Return a string describing this object.
@ OP_MAX
Pick the maximum weight of any subquery.
@ OP_XOR
Match documents which an odd number of subqueries match.
@ OP_AND_MAYBE
Match the first subquery taking extra weight from other subqueries.
@ OP_NEAR
Match only documents where all subqueries match near each other.
@ OP_ELITE_SET
Pick the best N subqueries and combine with OP_OR.
@ 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.
@ OP_PHRASE
Match only documents where all subqueries match near and in order.
@ OP_SYNONYM
Match like OP_OR but weighting as if a single term.
@ OP_AND_NOT
Match documents which the first subquery matches but no others do.
static const Xapian::Query MatchNothing
A query matching no documents.
static const Xapian::Query MatchAll
A query matching all documents.
void add_document(Xapian::docid did)
Add a document to the relevance set.
RangeError indicates an attempt to access outside the bounds of a container.
Base class for range processors.
RangeProcessor * release()
Start reference counting this object.
Abstract base class for stop-word decision functor.
Stopper * release()
Start reference counting this object.
Parses a piece of text and generate terms.
void index_text(const Xapian::Utf8Iterator &itor, Xapian::termcount wdf_inc=1, const std::string &prefix=std::string())
Index some text.
void set_document(const Xapian::Document &doc)
Set the current document.
void set_stopper(const Xapian::Stopper *stop=NULL)
Set the Xapian::Stopper object to be used for identifying stopwords.
Class for iterating over a list of terms.
Xapian::termcount positionlist_count() const
Return the length of the position list for the current position.
void skip_to(const std::string &term)
Advance the iterator to term term.
PositionIterator positionlist_end() const
Return an end PositionIterator for the current term.
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.
Base class for value range processors.
ValueRangeProcessor * release()
Start reference counting this object.
This class provides read/write access to a database.
void begin_transaction(bool flushed=true)
Begin a transaction.
void commit_transaction()
Complete the transaction currently in progress.
void cancel_transaction()
Abort the transaction currently in progress, discarding the pending modifications made to the databas...
string str(int value)
Convert int to std::string.
The Xapian namespace contains public interfaces for the Xapian library.
int major_version()
Report the major version of the library which the program is linked with.
int revision()
Report the revision of the library which the program is linked with.
unsigned valueno
The number for a value slot in a document.
const char * version_string()
Report the version string of the library which the program is linked with.
int minor_version()
Report the minor version of the library which the program is linked with.
unsigned XAPIAN_TERMPOS_BASE_TYPE termpos
A term position within a document or query.
Convert types to std::string.
bool startswith(const std::string &s, char pfx)
a generic test suite engine
#define FAIL_TEST(MSG)
Fail the current testcase with message MSG.
#define TEST_EQUAL(a, b)
Test for equality of two things.
#define TEST(a)
Test a condition, without an additional explanation for failure.
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.