42 map<string, Xapian::doccount> tally;
48 tout <<
"Collapsing on slot " << slot <<
" max " << cmax <<
'\n';
54 map<string, Xapian::doccount>::const_iterator i;
55 for (i = tally.begin(); i != tally.end(); ++i) {
56 if (i->first.empty() || i->second <= cmax) {
57 expect_size += i->second;
66 map<string, Xapian::doccount> seen;
68 const string & key = j.get_collapse_key();
69 TEST(tally.find(key) != tally.end());
72 for (i = tally.begin(); i != tally.end(); ++i) {
73 if (i->first.empty() || i->second <= cmax) {
94 for (
int percent = 65; percent != 100; ++percent) {
95 tout <<
"Collapsing on slot " << slot <<
" max " << cmax
96 <<
" cutoff " << percent <<
'\n';
101 TEST_REL(j.get_percent(), >=, percent);
DEFINE_TESTCASE(collapsekey5, backend)
Simple test of collapsing with collapse_max > 1.
Xapian::Database get_database(const string &dbname)
test functionality of the Xapian API
An indexed database of documents.
Xapian::doccount get_doccount() const
Get the number of documents in the database.
Xapian::Document get_document(Xapian::docid did, unsigned flags=0) const
Get a document from the database.
std::string get_value(Xapian::valueno slot) const
Read a value slot in this document.
MSet get_mset(doccount first, doccount maxitems, doccount checkatleast=0, const RSet *rset=NULL, const MatchDecider *mdecider=NULL) const
Run the query.
void set_cutoff(int percent_threshold, double weight_threshold=0)
Set lower bounds on percentage and/or weight.
void set_query(const Query &query, termcount query_length=0)
Set the query.
void set_collapse_key(valueno collapse_key, doccount collapse_max=1)
Control collapsing of results.
Iterator over a Xapian::MSet.
Class representing a list of search results.
Xapian::doccount size() const
Return number of items in this MSet object.
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.
unsigned valueno
The number for a value slot in a document.
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.
#define TEST_EQUAL(a, b)
Test for equality of two things.
#define TEST(a)
Test a condition, without an additional explanation for failure.
Xapian-specific test helper functions and macros.
Public interfaces for the Xapian library.