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");
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 } }
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 }
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 }
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"};
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())
#define WILDCARD_EXCEPTION
DEFINE_TESTCASE(queryterms1, !backend)
static const positional_testcase loosephrase1_testcases[]
static const wildcard_testcase wildcard1_testcases[]
static const positional_testcase loosenear1_testcases[]
static void gen_subdbwithoutpos1_db(Xapian::WritableDatabase &db, const string &)
Xapian::Database get_database(const string &dbname)
void XFAIL_FOR_BACKEND(const std::string &backend_prefix, const char *msg)
test functionality of the Xapian API
#define SKIP_TEST_FOR_BACKEND(B)
Class implementing a "boolean" weighting scheme.
This class is used to access a database, or a group of databases.
void add_database(const Database &database)
Add an existing database (or group of databases) to those accessed by this object.
Xapian::doccount get_doccount() const
Get the number of documents in the database.
A handle representing a document in a Xapian database.
void add_posting(const std::string &tname, Xapian::termpos tpos, Xapian::termcount wdfinc=1)
Add an occurrence of a term at a particular position.
void add_term(const std::string &tname, Xapian::termcount wdfinc=1)
Add a term to the document, without positional information.
This class provides an interface to the information retrieval system for the purpose of searching.
void set_query(const Xapian::Query &query, Xapian::termcount qlen=0)
Set the query to run.
TermIterator get_matching_terms_begin(Xapian::docid did) const
Get terms which match a given document, by document id.
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.
void set_weighting_scheme(const Weight &weight_)
Set the weighting scheme to use for queries.
TermIterator get_matching_terms_end(Xapian::docid) const
End iterator corresponding to get_matching_terms_begin()
Class representing a list of search results.
double get_termweight(const std::string &term) const
Get the term weight of a term.
Xapian::doccount size() const
Return number of items in this MSet object.
bool empty() const
Return true if this MSet object is empty.
Xapian::doccount get_matches_estimated() const
Estimate of the total number of matching documents.
Build a Xapian::Query object from a user query string.
Query parse_query(const std::string &query_string, unsigned flags=FLAG_DEFAULT, const std::string &default_prefix=std::string())
Parse a query.
Class representing a query.
@ WILDCARD_LIMIT_ERROR
Throw an error if OP_WILDCARD exceeds its expansion limit.
@ WILDCARD_LIMIT_FIRST
Stop expanding when OP_WILDCARD reaches its expansion limit.
@ WILDCARD_LIMIT_MOST_FREQUENT
Limit OP_WILDCARD expansion to the most frequent terms.
const Query get_subquery(size_t n) const
Read a top level subquery.
const TermIterator get_terms_begin() const
Begin iterator for terms in the query object.
const TermIterator get_unique_terms_begin() const
Begin iterator for unique terms in the query object.
const TermIterator get_terms_end() const
End iterator for terms in the query object.
std::string get_description() const
Return a string describing this object.
const TermIterator get_unique_terms_end() const
End iterator for unique terms in the query object.
@ OP_SCALE_WEIGHT
Scale the weight contributed by a subquery.
@ OP_WILDCARD
Wildcard expansion.
@ OP_XOR
Match documents which an odd number of subqueries match.
@ OP_AND_MAYBE
Match the first subquery taking extra weight from other subqueries.
@ LEAF_MATCH_ALL
Value returned by get_type() for MatchAll or equivalent.
@ OP_NEAR
Match only documents where all subqueries match near each other.
@ OP_AND
Match only documents which all subqueries match.
@ LEAF_MATCH_NOTHING
Value returned by get_type() for MatchNothing or equivalent.
@ OP_OR
Match documents which at least one subquery matches.
@ 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.
@ LEAF_TERM
Value returned by get_type() for a term.
@ OP_VALUE_GE
Match only documents where a value slot is >= a given value.
static const Xapian::Query MatchNothing
A query matching no documents.
size_t get_num_subqueries() const
Get the number of subqueries of the top level query.
op get_type() const
Get the type of the top level of the query.
static const Xapian::Query MatchAll
A query matching all documents.
UnimplementedError indicates an attempt to use an unimplemented feature.
A posting source which reads weights from a value slot.
WildcardError indicates an error expanding a wildcarded query.
This class provides read/write access to a database.
Xapian::docid add_document(const Xapian::Document &document)
Add a new document to the database.
The Xapian namespace contains public interfaces for the Xapian library.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
Xapian::termcount max_expansion
#define TEST_REL(A, REL, B)
Test a relation holds,e.g. TEST_REL(a,>,b);.
std::ostringstream tout
The debug printing stream.
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_STRINGS_EQUAL(a, b)
Test for equality of two strings.
#define TEST_EQUAL_DOUBLE(a, b)
Test two doubles for near equality.
#define TEST(a)
Test a condition, without an additional explanation for failure.
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)
bool mset_range_is_same(const Xapian::MSet &mset1, unsigned int first1, const Xapian::MSet &mset2, unsigned int first2, unsigned int count)
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.