45 std::vector<std::string>
seen;
81 std::vector<std::string> seen2;
82 for ( ; i != spymset.
end(); ++i) {
89 std::vector<std::string>::const_iterator j = myspy.
seen.begin();
90 std::vector<std::string>::const_iterator j2 = seen2.begin();
91 for (; j != myspy.
seen.end(); ++j, ++j2) {
97 string resultrepr(
"|");
103 resultrepr +=
str(i.get_termfreq());
112 for (
int c = 1; c <= 25; ++c) {
116 for (
int factor = 1; factor <= c; ++factor) {
118 if (c % factor == 0) {
163 static const char *
const results[] = {
164 "|1:1|2:9|3:3|4:7|5:1|6:3|8:1|",
165 "|0:2|1:3|2:3|3:3|4:3|5:3|6:2|7:2|8:2|9:2|",
216 static const char *
const results[] = {
217 "|2:9|4:7|3:3|6:3|1:1|5:1|8:1|",
218 "|1:3|2:3|3:3|4:3|5:3|0:2|6:2|7:2|8:2|9:2|",
221 "|2:9|4:7|3:3|6:3|1:1|5:1|8:1|",
222 "|1:3|2:3|3:3|4:3|5:3|0:2|6:2|7:2|8:2|9:2|",
227 std::vector<Xapian::ValueCountMatchSpy *> spies;
228 spies.push_back(&spya0);
229 spies.push_back(&spya1);
230 spies.push_back(NULL);
231 spies.push_back(&spya3);
232 spies.push_back(&spyb0);
233 spies.push_back(&spyb1);
234 spies.push_back(NULL);
235 spies.push_back(&spyb3);
237 tout <<
"value " << v <<
'\n';
239 string allvals_str(
"|");
241 size_t allvals_size = 0;
244 ++i, ++allvals_size) {
247 allvals_str +=
str(i.get_termfreq());
250 tout << allvals_str <<
'\n';
253 for (
size_t count = 0; count < allvals_size; ++count) {
254 tout <<
"count " << count <<
'\n';
260 tout <<
"j " << j <<
'\n';
262 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)
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.
An indexed database of documents.
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.
Class representing a document.
void set_data(std::string_view data)
Set the document data.
std::string get_data() const
Get the document data.
void add_term(std::string_view term, Xapian::termcount wdf_inc=1)
Add a term to this document.
void add_value(Xapian::valueno slot, std::string_view value)
Add a value to a slot in this document.
void set_weighting_scheme(const Weight &weight)
Set the weighting scheme to use.
void add_matchspy(MatchSpy *spy) XAPIAN_NONNULL()
Add a matchspy.
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.
void set_sort_by_value(valueno sort_key, bool reverse)
Set the sorting to be by value only.
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.
Class representing a query.
Registry for user subclasses.
Indicates an error in the std::string serialisation of an object.
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.
TermIterator top_values_end(size_t) const noexcept
End iterator corresponding to top_values_begin()
virtual void merge_results(const std::string &serialised)
Unserialise some results, and merge them into this matchspy.
size_t get_total() const noexcept
Return the total number of documents tallied.
TermIterator values_end() const noexcept
End iterator corresponding to values_begin()
TermIterator values_begin() const
Get an iterator over the values seen in the slot.
This class provides read/write access to a database.
Xapian::docid add_document(const Xapian::Document &doc)
Add a document to the database.
void sort(_RandomAccessIterator first, _RandomAccessIterator last, _Compare comp)
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.