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;
963 TEST_EQUAL(t.positionlist_count(), num_pos - 3);
969 TEST_EQUAL(t.positionlist_count(), num_pos - 4);
975 TEST_EQUAL(t.positionlist_count(), num_pos - 9);
980 static const Xapian::termpos expected[] = { 5, 8, 13, 21, 377, 610, 9999 };
982 for (
auto p = t.positionlist_begin(); p != t.positionlist_end(); ++p) {
1004 FAIL_TEST(
"Expected exception to be thrown");
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.
std::string get_description() const
Return a string describing this object.
void add_value(Xapian::valueno slot, const std::string &value)
Add a new value.
Xapian::Query operator()(const std::string &, const std::string &) override
Check for a valid range of this type.
TestFieldProcessor(bool &destroyed_)
TermIterator termlist_begin(Xapian::docid did) const
An iterator pointing to the start of the termlist for a given document.
#define TEST(a)
Test a condition, without an additional explanation for failure.
Xapian::Query operator()(const string &str) override
Convert a field-prefixed string to a Query object.
This class is used to access a database, or a group of databases.
bool operator()(const std::string &) const override
Is term a stop-word?
Xapian::termcount termlist_count() const
The length of the termlist - i.e.
MatchSpy * release()
Start reference counting this object.
static const Xapian::Query MatchAll
A query matching all documents.
Match documents which an odd number of subqueries match.
InvalidOperationError indicates the API was used in an invalid way.
void add_valuerangeprocessor(Xapian::ValueRangeProcessor *vrproc)
Register a ValueRangeProcessor.
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...
void set_document(const Xapian::Document &doc)
Set the current document.
Abstract base class for match spies.
void set_stopper(const Stopper *stop=NULL)
Set the stopper.
Parses a piece of text and generate terms.
ValueIterator values_begin() const
Iterator for the values in this document.
TermIterator allterms_end(const std::string &=std::string()) const
Corresponding end iterator to allterms_begin(prefix).
FieldProcessor * release()
Start reference counting this object.
Xapian::docid get_lastdocid() const
Get the highest document id which has been used in the database.
Build a Xapian::Query object from a user query string.
a generic test suite engine
DestroyedFlag(bool &destroyed_)
void remove_term(const std::string &tname)
Remove a term and all postings associated with it.
ExpandDecider subclass which rejects terms using two ExpandDeciders.
void skip_to(const std::string &term)
Advance the iterator to term term.
Pick the maximum weight of any subquery.
Convert types to std::string.
Virtual base class for expand decider functor.
int revision()
Report the revision of the library which the program is linked with.
ValueRangeProcessor * release()
Start reference counting this object.
Xapian::valueno operator()(std::string &, std::string &)
Check for a valid range of this type.
TestKeyMaker(bool &destroyed_)
void clear_terms()
Remove all terms (and postings) from the document.
TermIterator termlist_end() const
Equivalent end iterator for termlist_begin().
Base class for value range processors.
std::string get_metadata(const std::string &key) const
Get the user-specified metadata associated with a given key.
static const int INCLUDE_QUERY_TERMS
Terms in the query may be returned by get_eset().
void index_text(const Xapian::Utf8Iterator &itor, Xapian::termcount wdf_inc=1, const std::string &prefix=std::string())
Index some text.
void add_rangeprocessor(Xapian::RangeProcessor *range_proc, const std::string *grouping=NULL)
Register a RangeProcessor.
docid get_docid() const
Get the document id which is associated with this document (if any).
test functionality of the Xapian API
Stopper * release()
Start reference counting this object.
ExpandDecider * release()
Start reference counting this object.
const char * version_string()
Report the version string of the library which the program is linked with.
static void errorcopyctor_helper(Xapian::Error &error)
Class for iterating over a list of terms.
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.
TestMatchSpy(bool &destroyed_)
RangeError indicates an attempt to access outside the bounds of a container.
InvalidArgumentError indicates an invalid parameter value was passed to the API.
ValueIterator valuestream_end(Xapian::valueno) const
Return end iterator corresponding to valuestream_begin().
#define singlesubquery3_(OP)
void clear_values()
Remove all values associated with the document.
Base class for field processors.
Pick the best N subqueries and combine with OP_OR.
This class provides read/write access to a database.
int major_version()
Report the major version of the library which the program is linked with.
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.
bool operator()(const string &) const override
Do we want this term in the ESet?
Match only documents where all subqueries match near and in order.
Match the first subquery taking extra weight from other subqueries.
#define singlesubquery2_(OP)
#define singlesubquery1_(OP)
Public interfaces for the Xapian library.
Match like OP_AND but only taking weight from the first subquery.
#define TEST_EXCEPTION(TYPE, CODE)
Check that CODE throws exactly Xapian exception TYPE.
string str(int value)
Convert int to std::string.
Xapian::termcount get_doclength(Xapian::docid did) const
Get the length of a document.
Xapian::termcount values_count() const
Count the values in this document.
bool startswith(const std::string &s, char pfx)
string operator()(const Xapian::Document &) const override
Build a key string for a Document.
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.
ValueIterator values_end() const
Equivalent end iterator for values_begin().
TermIterator allterms_begin(const std::string &prefix=std::string()) const
An iterator which runs across all terms with a given prefix.
void set_stopper(const Xapian::Stopper *stop=NULL)
Set the Xapian::Stopper object to be used for identifying stopwords.
ValueIterator valuestream_begin(Xapian::valueno slot) const
Return an iterator over the value in slot slot for each document.
Base class for range processors.
void operator()(const Xapian::Document &, double) override
Register a document with the match spy.
TestStopper(bool &destroyed_)
Match like OP_OR but weighting as if a single term.
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 add_posting(const std::string &tname, Xapian::termpos tpos, Xapian::termcount wdfinc=1)
Add an occurrence of a term at a particular position.
TestRangeProcessor(bool &destroyed_)
void add_document(Xapian::docid did)
Add a document to the relevance set.
#define FAIL_TEST(MSG)
Fail the current testcase with message MSG.
Match only documents which all subqueries match.
Xapian::Database get_database(const string &dbname)
void add_matchspy(MatchSpy *spy)
Add a matchspy.
std::string get_description() const
Return a string describing this object.
This class provides an interface to the information retrieval system for the purpose of searching...
DEFINE_TESTCASE(version1, !backend)
Match only documents where all subqueries match near each other.
RangeProcessor * release()
Start reference counting this object.
TestValueRangeProcessor(bool &destroyed_)
bool empty() const
Check if this query is Xapian::Query::MatchNothing.
All exceptions thrown by Xapian are subclasses of Xapian::Error.
Match documents which the first subquery matches but no others do.
Match documents which at least one subquery matches.
unsigned valueno
The number for a value slot in a document.
Xapian-specific test helper functions and macros.
unsigned XAPIAN_TERMPOS_BASE_TYPE termpos
A term position within a document or query.
static const Xapian::Query MatchNothing
A query matching no documents.
Xapian::TermIterator metadata_keys_begin(const std::string &prefix=std::string()) const
An iterator which returns all user-specified metadata keys.
KeyMaker * release()
Start reference counting this object.
Abstract base class for stop-word decision functor.
void add_boolean_term(const std::string &term)
Add a boolean filter term to the document.
Class representing a query.
void add_prefix(const std::string &field, const std::string &prefix)
Add a free-text field term prefix.
TestExpandDecider(bool &destroyed_)
#define TEST_EQUAL(a, b)
Test for equality of two things.
Xapian::termcount get_unique_terms(Xapian::docid did) const
Get the number of unique terms in document.
void set_data(const std::string &data)
Set data stored in the document.
int minor_version()
Report the minor version of the library which the program is linked with.
TermIterator termlist_begin() const
Start iterating the terms in this document.
A handle representing a document in a Xapian database.
void remove_posting(const std::string &tname, Xapian::termpos tpos, Xapian::termcount wdfdec=1)
Remove a posting of a term from the document.
Xapian::termcount positionlist_count() const
Return the length of the position list for the current position.
void set_sort_by_key(Xapian::KeyMaker *sorter, bool reverse)
Set the sorting to be by key generated from values only.
Virtual base class for key making functors.
void add_term(const std::string &tname, Xapian::termcount wdfinc=1)
Add a term to the document, without positional information.
Xapian::TermIterator metadata_keys_end(const std::string &=std::string()) const
Corresponding end iterator to metadata_keys_begin().