46 std::vector<std::string>
seen;
80 std::sort(myspy.
seen.begin(), myspy.
seen.end());
82 std::vector<std::string> seen2;
83 for ( ; i != spymset.
end(); ++i) {
87 std::sort(seen2.begin(), seen2.end());
90 std::vector<std::string>::const_iterator j = myspy.
seen.begin();
91 std::vector<std::string>::const_iterator j2 = seen2.begin();
92 for (; j != myspy.
seen.end(); ++j, ++j2) {
98 string resultrepr(
"|");
104 resultrepr +=
str(i.get_termfreq());
113 for (
int c = 1; c <= 25; ++c) {
117 for (
int factor = 1; factor <= c; ++factor) {
119 if (c % factor == 0) {
164 static const char *
const results[] = {
165 "|1:1|2:9|3:3|4:7|5:1|6:3|8:1|",
166 "|0:2|1:3|2:3|3:3|4:3|5:3|6:2|7:2|8:2|9:2|",
177 "Matchspy counts hits on remote and locally");
179 "Matchspy counts hits on remote and locally");
222 static const char *
const results[] = {
223 "|2:9|4:7|3:3|6:3|1:1|5:1|8:1|",
224 "|1:3|2:3|3:3|4:3|5:3|0:2|6:2|7:2|8:2|9:2|",
227 "|2:9|4:7|3:3|6:3|1:1|5:1|8:1|",
228 "|1:3|2:3|3:3|4:3|5:3|0:2|6:2|7:2|8:2|9:2|",
233 std::vector<Xapian::ValueCountMatchSpy *> spies;
234 spies.push_back(&spya0);
235 spies.push_back(&spya1);
236 spies.push_back(NULL);
237 spies.push_back(&spya3);
238 spies.push_back(&spyb0);
239 spies.push_back(&spyb1);
240 spies.push_back(NULL);
241 spies.push_back(&spyb3);
243 tout <<
"value " << v <<
'\n';
245 string allvals_str(
"|");
247 size_t allvals_size = 0;
250 ++i, ++allvals_size) {
253 allvals_str +=
str(i.get_termfreq());
256 tout << allvals_str <<
'\n';
259 for (
size_t count = 0; count < allvals_size; ++count) {
260 tout <<
"count " << count <<
'\n';
266 tout <<
"j " << j <<
'\n';
268 TEST_EQUAL(i.get_termfreq(), j.get_termfreq());
static void make_matchspy2_db(Xapian::WritableDatabase &db, const string &)
DEFINE_TESTCASE(matchspy1, backend &&!remote)
static string values_to_repr(const Xapian::ValueCountMatchSpy &spy)
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
Base class for backend handling in test harness.
void operator()(const Xapian::Document &, double) override
Register a document with the match spy.
void operator()(const Xapian::Document &doc, double) override
Register a document with the match spy.
std::vector< std::string > seen
Xapian::Weight subclass implementing Coordinate Matching.
This class is used to access a database, or a group of databases.
size_t size() const
Return number of shards in this Database object.
Xapian::docid get_lastdocid() const
Get the highest document id which has been used in the database.
A handle representing a document in a Xapian database.
void add_value(Xapian::valueno slot, const std::string &value)
Add a new value.
std::string get_data() const
Get data stored in the document.
void add_term(const std::string &tname, Xapian::termcount wdfinc=1)
Add a term to the document, without positional information.
void set_data(const std::string &data)
Set data stored in the document.
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.
void add_matchspy(MatchSpy *spy)
Add a matchspy.
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_sort_by_value(Xapian::valueno sort_key, bool reverse)
Set the sorting to be by value only.
void set_weighting_scheme(const Weight &weight_)
Set the weighting scheme to use for queries.
Iterator over a Xapian::MSet.
Xapian::Document get_document() const
Get the Document object for the current position.
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.
Abstract base class for match spies.
virtual std::string name() const
Return the name of this match spy.
virtual std::string serialise() const
Return this object's parameters serialised as a single string.
virtual std::string get_description() const
Return a string describing this object.
virtual void merge_results(const std::string &serialised)
Unserialise some results, and merge them into this matchspy.
virtual std::string serialise_results() const
Serialise the results of this match spy.
virtual MatchSpy * clone() const
Clone the match spy.
virtual MatchSpy * unserialise(const std::string &serialised, const Registry &context) const
Unserialise parameters.
Indicates a problem communicating with a remote database.
Class representing a query.
Registry for user subclasses.
Class for iterating over a list of terms.
Xapian::doccount get_termfreq() const
Return the term frequency for the term at the current position.
UnimplementedError indicates an attempt to use an unimplemented feature.
Class for counting the frequencies of values in the matching documents.
TermIterator top_values_begin(size_t maxvalues) const
Get an iterator over the most frequent values seen in the slot.
virtual std::string serialise_results() const
Serialise the results of this match spy.
virtual void merge_results(const std::string &serialised)
Unserialise some results, and merge them into this matchspy.
TermIterator values_end() const
End iterator corresponding to values_begin()
TermIterator top_values_end(size_t) const
End iterator corresponding to top_values_begin()
TermIterator values_begin() const
Get an iterator over the values seen in the slot.
size_t get_total() const
Return the total number of documents tallied.
This class provides read/write access to a database.
Xapian::docid add_document(const Xapian::Document &document)
Add a new document to the database.
string str(int value)
Convert int to std::string.
unsigned valueno
The number for a value slot in a document.
Convert types to std::string.
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_STRINGS_EQUAL(a, b)
Test for equality of two strings.
#define TEST(a)
Test a condition, without an additional explanation for failure.
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.