26 #define XAPIAN_DEPRECATED(D) D
34 #include <string_view>
192 #define singlesubquery1_(OP) \
193 TEST_STRINGS_EQUAL(Xapian::Query(q->OP, q, q + 1).get_description(),\
211 #define singlesubquery2_(OP) \
212 TEST_STRINGS_EQUAL(Xapian::Query(q->OP, q, q + 1).get_description(),\
230 #define singlesubquery3_(OP) \
231 TEST_STRINGS_EQUAL(Xapian::Query(q->OP, q, q + 1).get_description(),\
232 "Query(<alldocuments>)")
260 #define pairwisequery1_(OP) do {\
261 auto expect = Xapian::Query(qa.OP, lit_a, lit_b).get_description(); \
262 TEST_STRINGS_EQUAL(expect, \
263 Xapian::Query(qa.OP, aa, ab).get_description()); \
264 TEST_STRINGS_EQUAL(expect, \
265 Xapian::Query(qa.OP, ca, cb).get_description()); \
266 TEST_STRINGS_EQUAL(expect, \
267 Xapian::Query(qa.OP, qa, qb).get_description()); \
311 :
Xapian::RangeProcessor(0), destroyed(destroyed_) { }
320 bool gone_auto, gone;
326 gone_auto = gone =
false;
408 bool gone_auto, gone;
414 gone_auto = gone =
false;
479 bool gone_auto, gone;
485 gone_auto = gone =
false;
543 bool operator()(
const std::string&)
const override {
return true; }
548 bool gone_auto, gone;
554 gone_auto = gone =
false;
625 bool gone_auto, gone;
631 gone_auto = gone =
false;
715 bool gone_auto, gone;
721 gone_auto = gone =
false;
796 bool operator()(
const string&)
const override {
return true; }
806 bool gone_auto, gone;
812 gone_auto = gone =
false;
822 (void)enq.
get_eset(5, rset, 0, &edecider_auto);
831 (void)enq.
get_eset(5, rset, 0, edecider);
865 edecider->
release()))->release());
878 &edecider_auto))->release());
888 doc.
set_data(
"\xc0\x80\xf5\x80\x80\x80\xfe\xff");
890 "Document(docid=0, data=\\xc0\\x80\\xf5\\x80\\x80\\x80\\xfe\\xff)");
891 doc.
set_data(
string(
"\x00\x1f", 2));
893 "Document(docid=0, data=\\x00\\x1f)");
897 "Document(docid=0, data=back\\x5cslash)");
917 for (
bool preinc : {
false,
true }) {
921 indexer.
index_text(
"Pull the rug out from under ourselves", 1,
"S");
925 const string&
term = *term_iterator;
929 if (preinc) ++term_iterator;
931 if (!preinc) ++term_iterator;
946 auto new_pos = prev_pos +
pos;
1004 static const Xapian::termpos expected[] = { 5, 8, 13, 21, 377, 610, 9999 };
1068 FAIL_TEST(
"Expected exception to be thrown");
1085 v.insert(v.begin(), eset.
begin(), eset.
end());
1091 vector<Xapian::docid> v;
1094 v.insert(v.begin(), mset.
begin(), mset.
end());
1100 vector<Xapian::termpos> v;
1113 vector<Xapian::docid> v;
DEFINE_TESTCASE(version1, !backend)
#define singlesubquery1_(OP)
#define singlesubquery3_(OP)
#define singlesubquery2_(OP)
static void errorcopyctor_helper(Xapian::Error &error)
#define pairwisequery1_(OP)
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_)
An indexed database of documents.
Xapian::TermIterator metadata_keys_begin(std::string_view prefix={}) const
An iterator which returns all user-specified metadata keys.
ValueIterator valuestream_begin(Xapian::valueno slot) const
Return an iterator over the value in slot slot for each document.
Xapian::termcount get_unique_terms_lower_bound() const
Get a lower bound on the unique terms size of a document in this DB.
PositionIterator positionlist_end(Xapian::docid, std::string_view) const noexcept
End iterator corresponding to positionlist_begin().
Xapian::termcount get_doclength_lower_bound() const
Get a lower bound on the length of a document in this DB.
PostingIterator postlist_begin(std::string_view term) const
Start iterating the postings of a term.
TermIterator termlist_begin(Xapian::docid did) const
Start iterating the terms in a document.
PositionIterator positionlist_begin(Xapian::docid did, std::string_view term) const
Start iterating positions for a term in a document.
Xapian::termcount get_doclength(Xapian::docid did) const
Get the length of a specified document.
Xapian::TermIterator metadata_keys_end(std::string_view={}) const noexcept
End iterator corresponding to metadata_keys_begin().
Xapian::termcount get_unique_terms_upper_bound() const
Get an upper bound on the unique terms size of a document in this DB.
TermIterator allterms_end(std::string_view={}) const noexcept
End iterator corresponding to allterms_begin(prefix).
Xapian::doccount get_doccount() const
Get the number of documents in the database.
PostingIterator postlist_end(std::string_view) const noexcept
End iterator corresponding to postlist_begin().
Xapian::docid get_lastdocid() const
Get the highest document id which has been used in the database.
TermIterator allterms_begin(std::string_view prefix={}) const
Start iterating all terms in the database with a given prefix.
ValueIterator valuestream_end(Xapian::valueno) const noexcept
Return end iterator corresponding to valuestream_begin().
Xapian::termcount get_doclength_upper_bound() const
Get an upper bound on the length of a document in this DB.
Xapian::Document get_document(Xapian::docid did, unsigned flags=0) const
Get a document from the database.
std::string get_metadata(std::string_view key) const
Get the user-specified metadata associated with a given key.
Xapian::termcount get_unique_terms(Xapian::docid did) const
Get the number of unique terms in a specified document.
Class representing a document.
void add_boolean_term(std::string_view term)
Add a boolean filter term to the document.
Xapian::docid get_docid() const
Get the document ID this document came from.
void set_data(std::string_view data)
Set 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.
void remove_term(std::string_view term)
Remove a term from this document.
void remove_posting(std::string_view term, Xapian::termpos term_pos, Xapian::termcount wdf_dec=1)
Remove posting for a term.
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.
void clear_values()
Clear all value slots in this document.
std::string get_description() const
Return a string describing this object.
void clear_terms()
Clear all terms from the document.
Xapian::termpos remove_postings(std::string_view 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_end() const noexcept
End iterator corresponding to values_begin().
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.
Class representing a list of search results.
ESetIterator end() const
Return iterator pointing to just after the last item in this ESet.
ESetIterator begin() const
Return iterator pointing to the first item in this ESet.
void add_matchspy(MatchSpy *spy) XAPIAN_NONNULL()
Add a matchspy.
void set_sort_by_key(KeyMaker *sorter, bool reverse) XAPIAN_NONNULL()
Set the sorting to be by key generated from values only.
ESet get_eset(termcount maxitems, const RSet &rset, int flags=0, const ExpandDecider *edecider=NULL, double min_weight=0.0) const
Perform query expansion.
void set_sort_by_relevance_then_key(KeyMaker *sorter, bool reverse) XAPIAN_NONNULL()
Set the sorting to be by relevance, then by keys generated from values.
void set_sort_by_key_then_relevance(KeyMaker *sorter, bool reverse) XAPIAN_NONNULL()
Set the sorting to be by keys generated from values, then by relevance for documents with identical k...
static const int INCLUDE_QUERY_TERMS
Flag telling get_eset() to allow query terms in Xapian::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.
Class representing a list of search results.
MSetIterator begin() const
Return iterator pointing to the first item in this MSet.
MSetIterator end() const
Return iterator pointing to just after the last item in this MSet.
Abstract base class for match spies.
MatchSpy * release()
Start reference counting this object.
Class for iterating over term positions.
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_prefix(std::string_view field, std::string_view prefix)
Add a free-text field term prefix.
void set_stopper(const Stopper *stop=NULL)
Set the stopper.
Class representing a query.
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.
bool empty() const noexcept
Check if this query is Xapian::Query::MatchNothing.
static const Xapian::Query MatchAll
A query matching all documents.
Class representing a set of documents judged as relevant.
void add_document(Xapian::docid did)
Mark a document as relevant.
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, std::string_view prefix={})
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.
void skip_to(std::string_view term)
Advance the iterator to term term.
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.
An iterator which returns Unicode character values from a UTF-8 encoded string.
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.
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.
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(std::string_view 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.