42 TEST_EQUAL(*query.get_unique_terms_begin(),
"fair");
70 "Query(<alldocuments>)");
76 vector<Xapian::Query> subqs;
118 # if __has_warning("-Wself-assign-overloaded") 121 # pragma clang diagnostic push 122 # pragma clang diagnostic ignored "-Wself-assign-overloaded" 127 # if __has_warning("-Wself-assign-overloaded") 128 # pragma clang diagnostic pop 157 # if __has_warning("-Wself-assign-overloaded") 160 # pragma clang diagnostic push 161 # pragma clang diagnostic ignored "-Wself-assign-overloaded" 166 # if __has_warning("-Wself-assign-overloaded") 167 # pragma clang diagnostic pop 196 # if __has_warning("-Wself-assign-overloaded") 199 # pragma clang diagnostic push 200 # pragma clang diagnostic ignored "-Wself-assign-overloaded" 205 # if __has_warning("-Wself-assign-overloaded") 206 # pragma clang diagnostic pop 239 q &= ~
Xapian::Query(
"bar");
241 q = ~
Xapian::Query(
"bar");
287 "Query(((a OR b) NEAR 2 (a OR b)))");
290 "Query(((a OR b) PHRASE 2 (a OR b)))");
343 static const char *
const subqs[] = {
344 "hack",
"which",
"paragraph",
"is",
"return" 372 "Query(\\xc0\\x80\\xf5\\x80\\x80\\x80\\xfe\\xff)");
374 "Query(\\x00\\x1f)");
377 "Query(back\\x5cslash)");
380 "Query(D\\x7f_\\x7f~)");
403 q = ~
Xapian::Query(
"bar");
415 TEST_EQUAL(q.get_subquery(0).get_type(), q.OP_OR);
420 TEST_EQUAL(q.get_subquery(0).get_type(), q.LEAF_TERM);
425 TEST_EQUAL(q.get_subquery(0).get_type(), q.LEAF_TERM);
426 TEST_EQUAL(q.get_subquery(1).get_type(), q.LEAF_TERM);
431 TEST_EQUAL(q.get_subquery(0).get_type(), q.LEAF_TERM);
432 TEST_EQUAL(q.get_subquery(1).get_type(), q.LEAF_TERM);
442 static const char *
const phrase[] = {
"this",
"is",
"the" };
456 const char * terms[4];
459 #define WILDCARD_EXCEPTION { 0, 0, 0, "" } 464 {
"thou", 1,
'E', {
"though", 0, 0, 0 } },
465 {
"s", 2,
'F', {
"say",
"search", 0, 0 } },
466 {
"s", 2,
'M', {
"simpl",
"so", 0, 0 } }
480 for (
auto&& test : wildcard1_testcases) {
481 tout << test.pattern <<
'\n';
482 auto tend = test.terms + 4;
483 while (tend[-1] == NULL) --tend;
484 bool expect_exception = (tend - test.terms == 4 && tend[-1][0] ==
'\0');
488 switch (test.max_type) {
501 q =
Xapian::Query(o, test.pattern, test.max_expansion, max_type);
508 TEST(!expect_exception);
515 TEST(expect_exception);
571 if (!terms.empty()) terms +=
' ';
590 const char * terms[4];
596 { 5, {
"expect",
"to",
"mset", 0 }, 0 },
597 { 5, {
"word",
"well",
"the", 0 }, 2 },
598 { 5, {
"if",
"word",
"doesnt", 0 }, 0 },
599 { 5, {
"at",
"line",
"three", 0 }, 0 },
600 { 5, {
"paragraph",
"other",
"the", 0 }, 0 },
601 { 5, {
"other",
"the",
"with", 0 }, 0 }
609 for (
auto&& test : loosephrase1_testcases) {
610 auto tend = test.terms + 4;
611 while (tend[-1] == NULL) --tend;
616 if (test.result == 0) {
627 { 4, {
"test",
"the",
"with", 0 }, 1 },
628 { 4, {
"expect",
"word",
"the", 0 }, 2 },
629 { 4, {
"line",
"be",
"blank", 0 }, 1 },
630 { 2, {
"banana",
"banana", 0, 0 }, 0 },
631 { 3, {
"banana",
"banana", 0, 0 }, 0 },
632 { 2, {
"word",
"word", 0, 0 }, 2 },
633 { 4, {
"work",
"meant",
"work", 0 }, 0 },
634 { 4, {
"this",
"one",
"yet",
"one" }, 0 }
642 for (
auto&& test : loosenear1_testcases) {
643 auto tend = test.terms + 4;
644 while (tend[-1] == NULL) --tend;
648 if (test.result == 0) {
806 "Known but obscure remote bug which doesn't justify " 807 "protocol version bump");
809 "Known but obscure remote bug which doesn't justify " 810 "protocol version bump");
854 Query q = Query(
"the") &~ (Query(
"friedrich") &
855 (Query(
"day") | Query(
"night")));
867 Query q = Query(
"the") &~ Query(Query::OP_WILDCARD,
"pru");
880 Query q(Query::OP_PHRASE, Query(
"the"), Query(
"king"));
881 q &= ~Query(
"worldtornado");
946 static const char*
const words[] = {
"hello",
"world"};
const TermIterator get_unique_terms_end() const
End iterator for unique terms in the query object.
The Xapian namespace contains public interfaces for the Xapian library.
Xapian::doccount size() const
Return number of items in this MSet object.
Xapian::docid add_document(const Xapian::Document &document)
Add a new document to the database.
const Query get_subquery(size_t n) const
Read a top level subquery.
Xapian::termcount max_expansion
#define TEST(a)
Test a condition, without an additional explanation for failure.
This class is used to access a database, or a group of databases.
TermIterator get_matching_terms_end(Xapian::docid) const
End iterator corresponding to get_matching_terms_begin()
static const Xapian::Query MatchAll
A query matching all documents.
Match documents which an odd number of subqueries match.
const TermIterator get_terms_begin() const
Begin iterator for terms in the query object.
bool mset_range_is_same(const Xapian::MSet &mset1, unsigned int first1, const Xapian::MSet &mset2, unsigned int first2, unsigned int count)
bool empty() const
Return true if this MSet object is empty.
Build a Xapian::Query object from a user query string.
WildcardError indicates an error expanding a wildcarded query.
a generic test suite engine
Class representing a list of search results.
MSet get_mset(Xapian::doccount first, Xapian::doccount maxitems, Xapian::doccount checkatleast=0, const RSet *omrset=0, const MatchDecider *mdecider=0) const
Get (a portion of) the match set for the current query.
Xapian::doccount get_doccount() const
Get the number of documents in the database.
const TermIterator get_unique_terms_begin() const
Begin iterator for unique terms in the query object.
#define WILDCARD_EXCEPTION
TermIterator get_matching_terms_begin(Xapian::docid did) const
Get terms which match a given document, by document id.
test functionality of the Xapian API
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
#define TEST_REL(A, REL, B)
Test a relation holds,e.g. TEST_REL(a,>,b);.
Class implementing a "boolean" weighting scheme.
Limit OP_WILDCARD expansion to the most frequent terms.
static const wildcard_testcase wildcard1_testcases[]
This class provides read/write access to a database.
Value returned by get_type() for MatchAll or equivalent.
std::ostringstream tout
The debug printing stream.
Match only documents where all subqueries match near and in order.
Match the first subquery taking extra weight from other subqueries.
Public interfaces for the Xapian library.
Match only documents where a value slot is >= a given value.
#define TEST_EXCEPTION(TYPE, CODE)
Check that CODE throws exactly Xapian exception TYPE.
static const positional_testcase loosenear1_testcases[]
static void gen_subdbwithoutpos1_db(Xapian::WritableDatabase &db, const string &)
Throw an error if OP_WILDCARD exceeds its expansion limit.
static const positional_testcase loosephrase1_testcases[]
double get_termweight(const std::string &term) const
Get the term weight of a term.
#define TEST_EQUAL_DOUBLE(a, b)
Test two doubles for near equality.
#define SKIP_TEST_FOR_BACKEND(B)
void add_database(const Database &database)
Add an existing database (or group of databases) to those accessed by this object.
void set_query(const Xapian::Query &query, Xapian::termcount qlen=0)
Set the query to run.
DEFINE_TESTCASE(queryterms1, !backend)
Match like OP_OR but weighting as if a single term.
void add_posting(const std::string &tname, Xapian::termpos tpos, Xapian::termcount wdfinc=1)
Add an occurrence of a term at a particular position.
A posting source which reads weights from a value slot.
#define FAIL_TEST(MSG)
Fail the current testcase with message MSG.
Match only documents which all subqueries match.
static Xapian::Query query(Xapian::Query::op op, const string &t1=string(), const string &t2=string(), const string &t3=string(), const string &t4=string(), const string &t5=string(), const string &t6=string(), const string &t7=string(), const string &t8=string(), const string &t9=string(), const string &t10=string())
Xapian::Database get_database(const string &dbname)
Xapian::doccount get_matches_estimated() const
Estimate of the total number of matching documents.
size_t get_num_subqueries() const
Get the number of subqueries of the top level query.
void XFAIL_FOR_BACKEND(const std::string &backend_prefix, const char *msg)
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...
Match only documents where all subqueries match near each other.
Value returned by get_type() for a term.
Match documents which the first subquery matches but no others do.
Match documents which at least one subquery matches.
Xapian-specific test helper functions and macros.
static const Xapian::Query MatchNothing
A query matching no documents.
#define TEST_STRINGS_EQUAL(a, b)
Test for equality of two strings.
Stop expanding when OP_WILDCARD reaches its expansion limit.
op get_type() const
Get the type of the top level of the query.
void mset_expect_order(const Xapian::MSet &A, Xapian::docid d1, Xapian::docid d2, Xapian::docid d3, Xapian::docid d4, Xapian::docid d5, Xapian::docid d6, Xapian::docid d7, Xapian::docid d8, Xapian::docid d9, Xapian::docid d10, Xapian::docid d11, Xapian::docid d12)
void set_weighting_scheme(const Weight &weight_)
Set the weighting scheme to use for queries.
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
Class representing a query.
#define TEST_EQUAL(a, b)
Test for equality of two things.
const TermIterator get_terms_end() const
End iterator for terms in the query object.
A handle representing a document in a Xapian database.
UnimplementedError indicates an attempt to use an unimplemented feature.
void add_term(const std::string &tname, Xapian::termcount wdfinc=1)
Add a term to the document, without positional information.
Value returned by get_type() for MatchNothing or equivalent.