45 static const test test_queries[] = {
46 {
"hello",
"(WILDCARD SYNONYM hello OR hello@1)" },
47 {
"~hello",
"(hello@1 SYNONYM hi@1 SYNONYM howdy@1)" },
48 {
"hello world",
"(hello@1 OR (WILDCARD SYNONYM world OR world@2))" },
49 {
"~hello world",
"((hello@1 SYNONYM hi@1 SYNONYM howdy@1) OR (WILDCARD SYNONYM world OR world@2))" },
50 {
"world ~hello",
"(world@1 OR (hello@2 SYNONYM hi@2 SYNONYM howdy@2))" },
53 static const test test_queries_auto[] = {
54 {
"hello",
"(hello@1 SYNONYM hi@1 SYNONYM howdy@1)" },
55 {
"~hello",
"(hello@1 SYNONYM hi@1 SYNONYM howdy@1)" },
56 {
"hello world",
"((hello@1 SYNONYM hi@1 SYNONYM howdy@1) OR world@2)" },
57 {
"~hello world",
"((hello@1 SYNONYM hi@1 SYNONYM howdy@1) OR world@2)" },
58 {
"world ~hello",
"(world@1 OR (hello@2 SYNONYM hi@2 SYNONYM howdy@2))" },
61 static const test test_queries_partial_auto[] = {
62 {
"hello",
"(WILDCARD SYNONYM hello OR hello@1)" },
63 {
"~hello",
"(WILDCARD SYNONYM hello OR hello@1)" },
64 {
"hello world",
"((hello@1 SYNONYM hi@1 SYNONYM howdy@1) OR (WILDCARD SYNONYM world OR world@2))" },
65 {
"~hello world",
"((hello@1 SYNONYM hi@1 SYNONYM howdy@1) OR (WILDCARD SYNONYM world OR world@2))" },
66 {
"world ~hello",
"(world@1 OR (WILDCARD SYNONYM hello OR hello@2))" },
83 for (p = test_queries; p->query; ++p) {
84 string expect, parsed;
88 expect =
"parse error";
93 expect = string(
"Query(") + expect +
')';
99 parsed =
"Unknown exception!";
101 tout <<
"Query: " << p->query <<
'\n';
105 for (p = test_queries_auto; p->query; ++p) {
106 string expect, parsed;
110 expect =
"parse error";
115 expect = string(
"Query(") + expect +
')';
121 parsed =
"Unknown exception!";
123 tout <<
"Query: " << p->query <<
'\n';
127 for (p = test_queries_partial_auto; p->query; ++p) {
128 string expect, parsed;
132 expect =
"parse error";
138 expect = string(
"Query(") + expect +
')';
144 parsed =
"Unknown exception!";
146 tout <<
"Query: " << p->query <<
'\n';
This class is used to access a database, or a group of databases.
Class representing a stemming algorithm.
const std::string & get_msg() const
Message giving details of the error, intended for human consumption.
Build a Xapian::Query object from a user query string.
a generic test suite engine
Indicates a query string can't be parsed.
DEFINE_TESTCASE(qpsynonympartial1, synonyms)
Regression test for bug#407 fixed in 1.0.17 and 1.1.3.
test functionality of the Xapian API
Base class for backend handling in test harness.
This class provides read/write access to a database.
std::ostringstream tout
The debug printing stream.
Public interfaces for the Xapian library.
Query parse_query(const std::string &query_string, unsigned flags=FLAG_DEFAULT, const std::string &default_prefix=std::string())
Parse a query.
std::string get_description() const
Return a string describing this object.
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)
Enable automatic use of synonyms for single terms.
void set_database(const Database &db)
Specify the database being searched.
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...
All exceptions thrown by Xapian are subclasses of Xapian::Error.
Xapian-specific test helper functions and macros.
#define TEST_STRINGS_EQUAL(a, b)
Test for equality of two strings.
void add_synonym(const std::string &term, const std::string &synonym) const
Add a synonym for a term.
Class representing a query.
void add_prefix(const std::string &field, const std::string &prefix)
Add a free-text field term prefix.
Enable synonym operator '~'.