56 #define NOQ Xapian::Query::MatchNothing
249 tout <<
"Comparing " << orquery <<
" with " << synquery <<
'\n';
255 map<Xapian::docid, double> values_or;
256 map<Xapian::docid, double> values_synonym;
258 values_or[*ormset[i]] = ormset[i].get_weight();
259 values_synonym[*synmset[i]] = synmset[i].get_weight();
261 TEST_EQUAL(values_or.size(), values_synonym.size());
266 int different_weight = 0;
267 for (map<Xapian::docid, double>::const_iterator
268 j = values_or.begin(); j != values_or.end(); ++j) {
272 TEST(values_synonym.find(did) != values_synonym.end());
273 if (values_or[did] == values_synonym[did]) {
280 TEST_EQUAL(different_weight, data.diffweight_count);
281 TEST_EQUAL(same_weight, data.sameweight_count);
295 vector<Xapian::Query> subqueries;
302 subqueries.push_back(
query);
312 tout << mset <<
'\n';
330 set<Xapian::docid> docids;
332 docids.insert(*mset1[i]);
340 TEST(docids.erase(*mset2[j]));
356 tout << mset_orig <<
'\n';
365 tout << mset_zero <<
'\n';
399 for (
auto op : operators) {
405 tout <<
"query1:" << query1 <<
'\n';
407 tout <<
"mset1:" << mset1 <<
'\n';
409 tout <<
"query2:" << query2 <<
'\n';
411 tout <<
"mset2:" << mset2 <<
'\n';
417 TEST(mset1[0].get_percent() != 100);
438 map<Xapian::docid, double> expected_weights;
440 for (i = mset1.
begin(); i != mset1.
end(); ++i) {
443 for (i = mset2.
begin(); i != mset2.
end(); ++i) {
444 map<Xapian::docid, double>::iterator j;
445 j = expected_weights.find(*i);
446 if (j != expected_weights.end()) {
453 for (i = msetmax.
begin(); i != msetmax.
end(); ++i) {
454 map<Xapian::docid, double>::iterator j;
455 j = expected_weights.find(*i);
456 TEST(j != expected_weights.end());
458 expected_weights.erase(j);
459 tout << expected_weights.size() <<
'\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(synonym1, backend)
static const synonym1_data_type synonym1_data[]
static void check_msets_contain_same_docs(const Xapian::MSet &mset1, const Xapian::MSet &mset2)
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.
Xapian::doccount get_doccount() const
Get the number of documents in the database.
Xapian::termcount get_doclength_upper_bound() const
Get an upper bound on the length of a document in this DB.
MSet get_mset(doccount first, doccount maxitems, doccount checkatleast=0, const RSet *rset=NULL, const MatchDecider *mdecider=NULL) const
Run the query.
void set_query(const Query &query, termcount query_length=0)
Set the query.
Iterator over a Xapian::MSet.
double get_weight() const
Get the weight for the current position.
Class representing a list of search results.
Xapian::doccount size() const
Return number of items in this MSet object.
double get_max_possible() const
The maximum possible weight any document could achieve.
MSetIterator begin() const
Return iterator pointing to the first item in this MSet.
MSetIterator end() const
Return iterator pointing to just after the last item in this MSet.
Class representing a query.
@ OP_SCALE_WEIGHT
Scale the weight contributed by a subquery.
@ OP_MAX
Pick the maximum weight of any subquery.
@ OP_XOR
Match documents which an odd number of subqueries match.
@ OP_AND_MAYBE
Match the first subquery taking extra weight from other subqueries.
@ OP_AND
Match only documents which all subqueries match.
@ 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.
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
#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 TEST_EQUAL(a, b)
Test for equality of two things.
#define TEST_EQUAL_DOUBLE(a, b)
Test two doubles for near equality.
#define TEST(a)
Test a condition, without an additional explanation for failure.
#define TEST_NOT_EQUAL(a, b)
Test for non-equality of two things.
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.
Public interfaces for the Xapian library.