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");
283 "Query(((a OR b) NEAR 2 (a OR b)))");
286 "Query(((a OR b) PHRASE 2 (a OR b)))");
339 static const char *
const subqs[] = {
340 "hack",
"which",
"paragraph",
"is",
"return" 368 "Query(\\xc0\\x80\\xf5\\x80\\x80\\x80\\xfe\\xff)");
370 "Query(\\x00\\x1f)");
373 "Query(back\\x5cslash)");
376 "Query(D\\x7f_\\x7f~)");
399 q = ~
Xapian::Query(
"bar");
411 TEST_EQUAL(q.get_subquery(0).get_type(), q.OP_OR);
416 TEST_EQUAL(q.get_subquery(0).get_type(), q.LEAF_TERM);
421 TEST_EQUAL(q.get_subquery(0).get_type(), q.LEAF_TERM);
422 TEST_EQUAL(q.get_subquery(1).get_type(), q.LEAF_TERM);
427 TEST_EQUAL(q.get_subquery(0).get_type(), q.LEAF_TERM);
428 TEST_EQUAL(q.get_subquery(1).get_type(), q.LEAF_TERM);
438 static const char *
const phrase[] = {
"this",
"is",
"the" };
452 const char * terms[4];
455 #define WILDCARD_EXCEPTION { 0, 0, 0, "" } 460 {
"thou", 1,
'E', {
"though", 0, 0, 0 } },
461 {
"s", 2,
'F', {
"say",
"search", 0, 0 } },
462 {
"s", 2,
'M', {
"simpl",
"so", 0, 0 } }
476 for (
auto&& test : wildcard1_testcases) {
477 tout << test.pattern << endl;
478 auto tend = test.terms + 4;
479 while (tend[-1] == NULL) --tend;
480 bool expect_exception = (tend - test.terms == 4 && tend[-1][0] ==
'\0');
484 switch (test.max_type) {
497 q =
Xapian::Query(o, test.pattern, test.max_expansion, max_type);
504 TEST(!expect_exception);
511 TEST(expect_exception);
552 const char * terms[4];
558 { 5, {
"expect",
"to",
"mset", 0 }, 0 },
559 { 5, {
"word",
"well",
"the", 0 }, 2 },
560 { 5, {
"if",
"word",
"doesnt", 0 }, 0 },
561 { 5, {
"at",
"line",
"three", 0 }, 0 },
562 { 5, {
"paragraph",
"other",
"the", 0 }, 0 },
563 { 5, {
"other",
"the",
"with", 0 }, 0 }
571 for (
auto&& test : loosephrase1_testcases) {
572 auto tend = test.terms + 4;
573 while (tend[-1] == NULL) --tend;
578 if (test.result == 0) {
589 { 4, {
"test",
"the",
"with", 0 }, 1 },
590 { 4, {
"expect",
"word",
"the", 0 }, 2 },
591 { 4, {
"line",
"be",
"blank", 0 }, 1 },
592 { 2, {
"banana",
"banana", 0, 0 }, 0 },
593 { 3, {
"banana",
"banana", 0, 0 }, 0 },
594 { 2, {
"word",
"word", 0, 0 }, 2 },
595 { 4, {
"work",
"meant",
"work", 0 }, 0 },
596 { 4, {
"this",
"one",
"yet",
"one" }, 0 }
604 for (
auto&& test : loosenear1_testcases) {
605 auto tend = test.terms + 4;
606 while (tend[-1] == NULL) --tend;
610 if (test.result == 0) {
768 "Known but obscure remote bug which doesn't justify " 769 "protocol version bump");
771 "Known but obscure remote bug which doesn't justify " 772 "protocol version bump");
816 Query q = Query(
"the") &~ (Query(
"friedrich") &
817 (Query(
"day") | Query(
"night")));
829 Query q = Query(
"the") &~ Query(Query::OP_WILDCARD,
"pru");
842 Query q(Query::OP_PHRASE, Query(
"the"), Query(
"king"));
843 q &= ~Query(
"worldtornado");
908 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.
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.
Xapian::WritableDatabase get_writable_database(const string &dbname)
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
test functionality of the Xapian API
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
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[]
#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.