44 static const test test_queries[] = {
45 {
"hello",
"(WILDCARD SYNONYM hello OR hello@1)" },
46 {
"~hello",
"(hello@1 SYNONYM hi@1 SYNONYM howdy@1)" },
47 {
"hello world",
"(hello@1 OR (WILDCARD SYNONYM world OR world@2))" },
48 {
"~hello world",
"((hello@1 SYNONYM hi@1 SYNONYM howdy@1) OR (WILDCARD SYNONYM world OR world@2))" },
49 {
"world ~hello",
"(world@1 OR (hello@2 SYNONYM hi@2 SYNONYM howdy@2))" },
52 static const test test_queries_auto[] = {
53 {
"hello",
"(hello@1 SYNONYM hi@1 SYNONYM howdy@1)" },
54 {
"~hello",
"(hello@1 SYNONYM hi@1 SYNONYM howdy@1)" },
55 {
"hello world",
"((hello@1 SYNONYM hi@1 SYNONYM howdy@1) OR world@2)" },
56 {
"~hello world",
"((hello@1 SYNONYM hi@1 SYNONYM howdy@1) OR world@2)" },
57 {
"world ~hello",
"(world@1 OR (hello@2 SYNONYM hi@2 SYNONYM howdy@2))" },
60 static const test test_queries_partial_auto[] = {
61 {
"hello",
"(WILDCARD SYNONYM hello OR hello@1)" },
62 {
"~hello",
"(WILDCARD SYNONYM hello OR hello@1)" },
63 {
"hello world",
"((hello@1 SYNONYM hi@1 SYNONYM howdy@1) OR (WILDCARD SYNONYM world OR world@2))" },
64 {
"~hello world",
"((hello@1 SYNONYM hi@1 SYNONYM howdy@1) OR (WILDCARD SYNONYM world OR world@2))" },
65 {
"world ~hello",
"(world@1 OR (WILDCARD SYNONYM hello OR hello@2))" },
82 for (
p = test_queries;
p->query; ++
p) {
83 string expect, parsed;
87 expect =
"parse error";
92 expect = string(
"Query(") + expect +
')';
98 parsed =
"Unknown exception!";
100 tout <<
"Query: " <<
p->query <<
'\n';
104 for (
p = test_queries_auto;
p->query; ++
p) {
105 string expect, parsed;
109 expect =
"parse error";
114 expect = string(
"Query(") + expect +
')';
120 parsed =
"Unknown exception!";
122 tout <<
"Query: " <<
p->query <<
'\n';
126 for (
p = test_queries_partial_auto;
p->query; ++
p) {
127 string expect, parsed;
131 expect =
"parse error";
137 expect = string(
"Query(") + expect +
')';
143 parsed =
"Unknown exception!";
145 tout <<
"Query: " <<
p->query <<
'\n';
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_TESTCASE(qpsynonympartial1, synonyms)
Regression test for bug#407 fixed in 1.0.17 and 1.1.3.
Xapian::Database get_database(const string &dbname)
test functionality of the Xapian API
Base class for backend handling in test harness.
An indexed database of documents.
All exceptions thrown by Xapian are subclasses of Xapian::Error.
const std::string & get_msg() const noexcept
Message giving details of the error, intended for human consumption.
std::string get_description() const
Return a string describing this object.
Indicates a query string can't be parsed.
Build a Xapian::Query object from a user query string.
void set_database(const Database &db)
Specify the database being searched.
void add_prefix(std::string_view field, std::string_view prefix)
Add a free-text field term prefix.
Query parse_query(std::string_view query_string, unsigned flags=FLAG_DEFAULT, std::string_view default_prefix={})
Parse a query.
@ FLAG_AUTO_SYNONYMS
Enable automatic use of synonyms for single terms.
@ FLAG_DEFAULT
The default flags.
@ FLAG_SYNONYM
Enable synonym operator '~'.
@ FLAG_PARTIAL
Enable partial matching.
Class representing a query.
std::string get_description() const
Return a string describing this object.
Class representing a stemming algorithm.
This class provides read/write access to a database.
void add_synonym(std::string_view term, std::string_view synonym) const
Add a synonym for a term.
std::ostringstream tout
The debug printing stream.
a generic test suite engine
#define TEST_STRINGS_EQUAL(a, b)
Test for equality of two strings.
Xapian-specific test helper functions and macros.
Public interfaces for the Xapian library.