73 const char * dbpath =
".stub/stubdb1";
98 const char * dbpath =
".stub/stubdb2";
111 #ifdef XAPIAN_HAS_REMOTE_BACKEND 122 #ifdef XAPIAN_HAS_REMOTE_BACKEND 142 #ifdef XAPIAN_HAS_REMOTE_BACKEND 143 # define EXPECTED_EXCEPTION Xapian::DatabaseOpeningError 145 # define EXPECTED_EXCEPTION Xapian::FeatureUnavailableError 150 out <<
"remote foo\n";
163 #ifdef XAPIAN_HAS_REMOTE_BACKEND 166 out <<
"remote [::1]:65535\n";
206 out <<
"remote [::1]\n";
224 mkdir(
".stub", 0755);
225 const char * dbpath =
".stub/stubdb3";
226 ofstream out(dbpath);
241 mkdir(
".stub", 0755);
242 const char * dbpath =
".stub/stubdb4";
243 ofstream out(dbpath);
245 out <<
"bad line here\n";
258 mkdir(
".stub", 0755);
259 const char * dbpath =
".stub/stubdb5";
260 ofstream out(dbpath);
275 mkdir(
".stub", 0755);
276 const char * dbpath =
".stub/stubdb6";
277 ofstream out(dbpath);
321 mkdir(
".stub", 0755);
322 const char * dbpath =
".stub/stubdb8";
323 ofstream out(dbpath);
330 FAIL_TEST(
"Managed to check inmemory stub");
334 "InMemory database checking not implemented");
340 mkdir(
".stub", 0755);
341 const char * dbpath =
".stub/stubdb9";
342 ofstream out(dbpath);
350 FAIL_TEST(
"Managed to check remote stub");
354 "Remote database checking not implemented");
358 #if 0 // the "force error" mechanism is no longer in place... 366 <<
", count is now " << count <<
"\n";
370 MyErrorHandler() : count (0) {}
375 MyErrorHandler myhandler;
380 for (
int testcount = 0; testcount < 14; testcount ++) {
381 tout <<
"testcount=" << testcount <<
"\n";
463 tout <<
"db=" << dbs <<
"\n";
471 tout <<
"query=" << myquery <<
"\n";
476 case 0:
case 3:
case 6:
case 9:
479 case 1:
case 4:
case 7:
case 10:
482 case 2:
case 5:
case 8:
case 11:
505 return doc.
get_data().find(needle) != string::npos;
532 for ( ; i != mymset.
end(); ++i) {
534 TEST(myfunctor(doc));
535 docid_checked[*i] =
true;
545 mymset = enquire.
get_mset(0, 0, 0, &myfunctor);
547 TEST_EQUAL(mymset.get_matches_lower_bound(), 0);
548 TEST_EQUAL(mymset.get_matches_upper_bound(), 6);
549 TEST_REL(mymset.get_matches_estimated(),>,0);
550 TEST_REL(mymset.get_matches_estimated(),<=,6);
551 TEST_EQUAL(mymset.get_uncollapsed_matches_lower_bound(), 0);
552 TEST_EQUAL(mymset.get_uncollapsed_matches_upper_bound(), 6);
553 TEST_REL(mymset.get_uncollapsed_matches_estimated(),>,0);
554 TEST_REL(mymset.get_uncollapsed_matches_estimated(),<=,6);
559 mymset = enquire.
get_mset(0, 1, 0, &myfunctor);
561 TEST_REL(mymset.get_matches_lower_bound(),>=,1);
562 TEST_REL(mymset.get_matches_lower_bound(),<=,3);
563 TEST_REL(mymset.get_matches_upper_bound(),>=,3);
564 TEST_REL(mymset.get_matches_upper_bound(),<=,6);
565 TEST_REL(mymset.get_matches_estimated(),>,0);
566 TEST_REL(mymset.get_matches_estimated(),<=,6);
567 TEST_REL(mymset.get_uncollapsed_matches_lower_bound(),>=,1);
568 TEST_REL(mymset.get_uncollapsed_matches_lower_bound(),<=,3);
569 TEST_REL(mymset.get_uncollapsed_matches_upper_bound(),>=,3);
570 TEST_REL(mymset.get_uncollapsed_matches_upper_bound(),<=,6);
571 TEST_REL(mymset.get_uncollapsed_matches_estimated(),>,0);
572 TEST_REL(mymset.get_uncollapsed_matches_estimated(),<=,6);
575 for (
Xapian::docid did = 1; did < docid_checked.size(); ++did) {
576 if (!docid_checked[did]) {
584 mymset = enquire.
get_mset(0, 1, 0, &myfunctor);
586 TEST_REL(mymset.get_matches_lower_bound(),>=,1);
587 TEST_REL(mymset.get_matches_lower_bound(),<=,3);
588 TEST_REL(mymset.get_matches_upper_bound(),>=,3);
589 TEST_REL(mymset.get_matches_upper_bound(),<=,6);
590 TEST_REL(mymset.get_matches_estimated(),>,0);
591 TEST_REL(mymset.get_matches_estimated(),<=,6);
592 TEST_REL(mymset.get_uncollapsed_matches_lower_bound(),>=,1);
593 TEST_REL(mymset.get_uncollapsed_matches_lower_bound(),<=,3);
594 TEST_REL(mymset.get_uncollapsed_matches_upper_bound(),>=,3);
595 TEST_REL(mymset.get_uncollapsed_matches_upper_bound(),<=,6);
596 TEST_REL(mymset.get_uncollapsed_matches_estimated(),>,0);
597 TEST_REL(mymset.get_uncollapsed_matches_estimated(),<=,6);
603 mymset = enquire.
get_mset(0, 1, 0, &myfunctor);
605 TEST_REL(mymset.get_matches_lower_bound(),>=,1);
606 TEST_REL(mymset.get_matches_lower_bound(),<=,3);
607 TEST_REL(mymset.get_matches_upper_bound(),>=,3);
608 TEST_REL(mymset.get_matches_upper_bound(),<=,6);
609 TEST_REL(mymset.get_matches_estimated(),>,0);
610 TEST_REL(mymset.get_matches_estimated(),<=,6);
611 TEST_REL(mymset.get_uncollapsed_matches_lower_bound(),>=,1);
612 TEST_REL(mymset.get_uncollapsed_matches_lower_bound(),<=,3);
613 TEST_REL(mymset.get_uncollapsed_matches_upper_bound(),>=,3);
614 TEST_REL(mymset.get_uncollapsed_matches_upper_bound(),<=,6);
615 TEST_REL(mymset.get_uncollapsed_matches_estimated(),>,0);
616 TEST_REL(mymset.get_uncollapsed_matches_estimated(),<=,6);
620 mymset = enquire.
get_mset(0, 1, 0, &myfunctor);
622 TEST_REL(mymset.get_matches_lower_bound(),>=,1);
623 TEST_REL(mymset.get_matches_lower_bound(),<=,3);
624 TEST_REL(mymset.get_matches_upper_bound(),>=,3);
625 TEST_REL(mymset.get_matches_upper_bound(),<=,6);
626 TEST_REL(mymset.get_matches_estimated(),>,0);
627 TEST_REL(mymset.get_matches_estimated(),<=,6);
628 TEST_REL(mymset.get_uncollapsed_matches_lower_bound(),>=,1);
629 TEST_REL(mymset.get_uncollapsed_matches_lower_bound(),<=,3);
630 TEST_REL(mymset.get_uncollapsed_matches_upper_bound(),>=,3);
631 TEST_REL(mymset.get_uncollapsed_matches_upper_bound(),<=,6);
632 TEST_REL(mymset.get_uncollapsed_matches_estimated(),>,0);
633 TEST_REL(mymset.get_uncollapsed_matches_estimated(),<=,6);
653 for ( ; i != mymset.
end(); ++i) {
655 TEST(myfunctor(doc));
656 docid_checked[*i] =
true;
660 for (
Xapian::docid did = 1; did < docid_checked.size(); ++did) {
661 if (!docid_checked[did]) {
779 TEST(!doc.get_data().empty());
792 myrset.add_document(*i);
793 myrset.add_document(*(++i));
839 myrset.add_document(*i);
840 myrset.add_document(*(++i));
868 "Had no fewer items when performing collapse: don't know whether it worked.");
870 map<string, Xapian::docid> values;
872 for ( ; i != mymset.
end(); ++i) {
874 TEST(values[value] == 0 || value.empty());
883 SKIP_TEST(
"Don't have a suitable database currently");
917 "Lower bound was not lower when performing collapse: don't know whether it worked.");
919 "Upper bound was not lower when performing collapse: don't know whether it worked.");
921 map<string, Xapian::docid> values;
923 for ( ; i != mymset.
end(); ++i) {
925 TEST(values[value] == 0 || value.empty());
943 map<string, Xapian::docid> values;
945 for ( ; i != mymset.
end(); ++i) {
947 TEST(values[value] == 0 || value.empty());
966 "Lower bound was not 1 when performing collapse but not asking for any results.");
968 "Upper bound was changed when performing collapse but not asking for any results.");
970 map<string, Xapian::docid> values;
972 for ( ; i != mymset.
end(); ++i) {
974 TEST(values[value] == 0 || value.empty());
985 for (
int i = 0; i < 10; ++i) {
1016 tout <<
"*ati = '" << *ati <<
"'\n";
1017 tout <<
"*ati.length = '" << (*ati).length() <<
"'\n";
1018 tout <<
"*ati == \"one\" = " << (*ati ==
"one") <<
"\n";
1019 tout <<
"*ati[3] = " << ((*ati)[3]) <<
"\n";
1020 tout <<
"*ati = '" << *ati <<
"'\n";
1022 TEST(*ati ==
"three");
1027 TEST(*ati2 ==
"one");
1028 TEST(ati2.get_termfreq() == 1);
1036 TEST(*ati ==
"two");
1037 TEST(ati.get_termfreq() == 2);
1041 TEST(*ati2 ==
"three");
1042 TEST(ati2.get_termfreq() == 3);
1057 TEST(*ati ==
"five");
1062 TEST(*ati ==
"four");
1063 TEST(ati.get_termfreq() == 1);
1067 TEST(*ati ==
"one");
1068 TEST(ati.get_termfreq() == 1);
1072 TEST(*ati ==
"six");
1073 TEST(ati.get_termfreq() == 3);
1077 TEST(*ati ==
"three");
1078 TEST(ati.get_termfreq() == 3);
1082 TEST(*ati ==
"two");
1083 TEST(ati.get_termfreq() == 2);
1095 ati.
skip_to(
string(
"zzzzzz"));
1143 ati.skip_to(
"three");
1153 ati.skip_to(
"three");
1181 for (m = mymset.
begin(); m != mymset.
end(); ++m) ++count;
1187 if (value_no == 0) {
1188 TEST(value.size() > 263);
1189 TEST_EQUAL(static_cast<unsigned char>(value[262]), 255);
1190 for (
int k = 0; k < 256; ++k) {
1191 TEST_EQUAL(static_cast<unsigned char>(value[k + 7]), k);
1200 for (m = mymset.
begin(); m != mymset.
end(); ++m) ++count;
1226 t.
skip_to(
string(
"big\0zero", 8));
1298 while (i != eset1.
end() && j != eset3.
end()) {
1307 bool eset1_eq_eset2 =
true;
1310 while (i != eset1.
end() && j != eset2.
end()) {
1312 eset1_eq_eset2 =
false;
1318 TEST(!eset1_eq_eset2);
1327 string s =
"let_us_see_if_we_can_break_it_with_a_really_really_long_term.";
1328 for (
int i = 0; i < 8; ++i) {
1350 TEST(p_copy.get_description() !=
"PostingIterator()");
1356 TEST(p_clone.get_description() !=
"PostingIterator()");
1358 vector<Xapian::docid> v(p, pend);
1362 vector<Xapian::docid>::const_iterator i;
1363 for (i = v.begin(); i != v.end(); ++i) {
1447 TEST_EQUAL(db1.get_collection_freq(
"this"), 15);
1448 TEST_EQUAL(db1.get_collection_freq(
"first"), 1);
1449 TEST_EQUAL(db1.get_collection_freq(
"last"), 0);
1450 TEST_EQUAL(db1.get_collection_freq(
"word"), 11);
1462 for (
int pass = 1; pass <= 2; ++pass) {
1464 tout <<
"Sorting on value " << value_no <<
'\n';
1474 j = allbset.
begin();
1475 for (i = partbset1.
begin(); i != partbset1.
end(); ++i) {
1476 tout <<
"Entry " << n <<
": " << *i <<
" | " << *j <<
'\n';
1478 if (*i != *j) ok =
false;
1483 for (i = partbset2.
begin(); i != partbset2.
end(); ++i) {
1484 tout <<
"Entry " << n <<
": " << *i <<
" | " << *j <<
'\n';
1486 if (*i != *j) ok =
false;
1492 FAIL_TEST(
"Split msets aren't consistent with unsplit");
1515 min(start + size, bigmset.
size()));
1523 bigmset[start + i].get_weight());
1536 #ifdef XAPIAN_HAS_CHERT_BACKEND 1537 mkdir(
".chert", 0755);
1546 mkdir(
".chert/emptydirectory", 0700);
1551 touch(
".chert/somefile");
1574 #ifdef XAPIAN_HAS_GLASS_BACKEND 1575 mkdir(
".glass", 0755);
1584 mkdir(
".glass/emptydirectory", 0700);
1589 touch(
".glass/somefile");
1621 string empty_dir =
"emptydirectory";
1622 mkdir(empty_dir.c_str(), 0700);
1629 #ifdef XAPIAN_HAS_CHERT_BACKEND 1630 const string dbdir =
".chert/test_chertdatabaseopen1";
1631 mkdir(
".chert", 0755);
1698 static const Xapian::docid order1[] = { 1,2,3,4,5,6,7,8,9 };
1699 static const Xapian::docid order2[] = { 2,1,3,6,5,4,7,9,8 };
1700 static const Xapian::docid order3[] = { 3,2,1,6,5,4,9,8,7 };
1701 static const Xapian::docid order4[] = { 7,8,9,4,5,6,1,2,3 };
1702 static const Xapian::docid order5[] = { 9,8,7,6,5,4,3,2,1 };
1703 static const Xapian::docid order6[] = { 7,9,8,6,5,4,2,1,3 };
1704 static const Xapian::docid order7[] = { 7,9,8,6,5,4,2,1,3 };
1705 static const Xapian::docid order8[] = { 2,6,7,1,5,9,3,4,8 };
1706 static const Xapian::docid order9[] = { 7,6,2,9,5,1,8,4,3 };
1713 for (i = 0; i <
sizeof(order1) /
sizeof(
Xapian::docid); ++i) {
1721 for (i = 0; i <
sizeof(order2) /
sizeof(
Xapian::docid); ++i) {
1729 for (i = 0; i <
sizeof(order1) /
sizeof(
Xapian::docid); ++i) {
1738 for (i = 0; i <
sizeof(order2) /
sizeof(
Xapian::docid); ++i) {
1747 for (i = 0; i <
sizeof(order3) /
sizeof(
Xapian::docid); ++i) {
1755 for (i = 0; i <
sizeof(order4) /
sizeof(
Xapian::docid); ++i) {
1763 for (i = 0; i <
sizeof(order5) /
sizeof(
Xapian::docid); ++i) {
1771 for (i = 0; i <
sizeof(order6) /
sizeof(
Xapian::docid); ++i) {
1779 for (i = 0; i <
sizeof(order7) /
sizeof(
Xapian::docid); ++i) {
1787 for (i = 0; i <
sizeof(order8) /
sizeof(
Xapian::docid); ++i) {
1795 for (i = 0; i <
sizeof(order8) /
sizeof(
Xapian::docid); ++i) {
1803 for (i = 0; i <
sizeof(order9) /
sizeof(
Xapian::docid); ++i) {
1811 for (i = 0; i <
sizeof(order9) /
sizeof(
Xapian::docid); ++i) {
1819 static const struct {
Xapian::docid did;
const char* text; } content[] = {
1820 {1,
"This is a test document used with the API test. This paragraph " 1821 "must be at least three lines (including the blank line) to be " 1822 "counted as a \"paragraph\"."},
1823 {2,
"This is a second simple data test, used to test multiple " 1824 "(inmemory anyway) databases. The text in this file is " 1825 "unimportant, although I suppose it ought to include the " 1826 "standard word \"word\" in a few places."},
1827 {3,
"This file will be indexed by paragraph, and the simple query will " 1828 "search for the word \"word\". Well expect the mset to contain " 1829 "two documents, including this paragraph and the fourth, below. " 1830 "Since this paragraph uses the word \"word\" so much, this " 1831 "should be the first one in the match set. Ill just say the word " 1832 "a few more times (word!) to make sure of that. If this doesnt " 1833 "word (typo, I meant work), then there may be fourletter words " 1835 {4,
"Ill leave this at two paragraphs. This one hasnt got any useful " 1836 "information in it either."},
1837 {5,
"This paragraph only has a load of absolute rubbish, and nothing " 1838 "of any use whatsoever."},
1839 {7,
"This is the other paragraph with the word in the simple query " 1840 "in it. For simplicity, all paragraphs are at least two lines, " 1841 "due to how the hacked up indexer works."},
1842 {9,
"This is another paragraph which wont be returned. Well, not " 1843 "with the simple query, anyway."},
1844 {11,
"And yet another. This one does mention banana splits, though, " 1845 "so cant be that bad."}
1852 for (
auto& i : content) {
1864 static const char *
const words[] = {
"paragraph",
"word" };
1866 const size_t MSET_SIZE = 10;
1884 static const pair<Xapian::docid, double> to_compare[] = {
1885 {7, 1.445962071042388164},
1886 {3, 1.4140112748017070743},
1887 {1, 1.3747698831232337824},
1888 {5, 1.1654938419498412916},
1889 {9, 1.1654938419498412916},
1890 {4, 1.1543806706320836053},
1891 {2, 0.12268031290495594321}
1906 void init(
double factor)
override {
1907 scale_factor = factor;
1911 std::string
name()
const override {
return "MyWeight"; }
1919 return scale_factor;
1936 static const char *
const query[] = {
1937 "this",
"line",
"paragraph",
"rubbish" 1940 query +
sizeof(query) /
sizeof(query[0])));
1993 mset_expect_order(mymset, 8, 6, 4, 5, 7, 10, 12, 11, 13, 9, 14);
1994 mymset = enq.
get_mset(0, 20, 0, NULL, &vsmd1);
1996 mymset = enq.
get_mset(0, 20, 0, NULL, &vsmd2);
#define TEST_MSET_SIZE(M, S)
Check MSet M has size S.
static void make_netstats1_db(Xapian::WritableDatabase &db, const string &)
static const char * get_xapian_progsrv_command()
Get the command line required to run xapian-progsrv.
Xapian::doccount size() const
Return number of items in this MSet object.
Xapian::Document get_document(Xapian::docid did) const
Get a document from the database, given its document id.
Xapian::docid add_document(const Xapian::Document &document)
Add a new document to the database.
MatchDecider filtering results based on whether document values are in a user-defined set...
void set_sort_by_value_then_relevance(Xapian::valueno sort_key, bool reverse)
Set the sorting to be by value, then by relevance for documents with the same value.
static size_t check(const std::string &path, int opts=0, std::ostream *out=NULL)
Check the integrity of a database or database table.
void init(double factor) override
Allow the subclass to perform any initialisation it needs to.
void set_docid_order(docid_order order)
Set sort order for document IDs.
double get_sumpart(Xapian::termcount, Xapian::termcount, Xapian::termcount) const override
Calculate the weight contribution for this object's term to a document.
#define TEST(a)
Test a condition, without an additional explanation for failure.
#define TEST_EXCEPTION_BASE_CLASS(TYPE, CODE)
Check that CODE throws Xapian exception derived from TYPE.
This class is used to access a database, or a group of databases.
void set_sort_by_value(Xapian::valueno sort_key, bool reverse)
Set the sorting to be by value only.
double get_sumextra(Xapian::termcount, Xapian::termcount) const override
Calculate the term-independent weight component for a document.
Xapian::termcount get_wdf() const
Return the wdf for the document at the current position.
TermIterator get_matching_terms_end(Xapian::docid) const
End iterator corresponding to get_matching_terms_begin()
static const Xapian::Query MatchAll
A query matching all documents.
void set_cutoff(int percent_cutoff, double weight_cutoff=0)
Set the percentage and/or weight cutoffs.
const int DB_CREATE
Create a new database.
DatabaseOpeningError indicates failure to open a database.
Class representing a stemming algorithm.
void set_document(const Xapian::Document &doc)
Set the current document.
bool mset_range_is_same(const Xapian::MSet &mset1, unsigned int first1, const Xapian::MSet &mset2, unsigned int first2, unsigned int count)
Parses a piece of text and generate terms.
Indicates a timeout expired while communicating with a remote database.
#define TEST_AND_EXPLAIN(a, b)
Test a condition, and display the test with an extra explanation if the condition fails...
bool empty() const
Return true if this MSet object is empty.
void set_stemming_strategy(stem_strategy strategy)
Set the stemming strategy.
Xapian::doccount get_matches_lower_bound() const
Lower bound on the total number of matching documents.
bool operator()(const Xapian::Document &doc) const override
Decide whether we want this document to be in the MSet.
#define EXPECTED_EXCEPTION
TermIterator allterms_end(const std::string &=std::string()) const
Corresponding end iterator to allterms_begin(prefix).
Xapian::docid get_lastdocid() const
Get the highest document id which has been used in the database.
double get_max_attained() const
The maximum weight attained by any document.
const std::string & get_msg() const
Message giving details of the error, intended for human consumption.
void sleep(double t)
Sleep until the time represented by this object.
a generic test suite engine
Xapian::doccount get_termfreq() const
Return the term frequency for the term at the current position.
static const int USE_EXACT_TERMFREQ
Calculate exact term frequencies in get_eset().
void add_value(const std::string &value)
Add a value to the test set.
C++ function versions of useful Unix commands.
Class representing a list of search results.
void skip_to(const std::string &term)
Advance the iterator to term term.
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.
const int DB_CREATE_OR_OPEN
Create database if it doesn't already exist.
include <netdb.h>, with portability workarounds.
void replace_document(Xapian::docid did, const Xapian::Document &document)
Replace a given document in the database.
static Xapian::Stem stemmer
Xapian::doccount get_doccount() const
Get the number of documents in the database.
include <sys/stat.h> with portability enhancements
double get_weight() const
Get the weight for the current position.
void index_text(const Xapian::Utf8Iterator &itor, Xapian::termcount wdf_inc=1, const std::string &prefix=std::string())
Index some text.
const int DB_BACKEND_GLASS
Use the glass backend.
TermIterator get_matching_terms_begin(Xapian::docid did) const
Get terms which match a given document, by document id.
test functionality of the Xapian API
void rm_rf(const string &filename)
Remove a directory and contents, just like the Unix "rm -rf" command.
Xapian::doccount get_matches_upper_bound() const
Upper bound on the total number of matching documents.
Xapian::doclength get_avlength() const
Get the average length of the documents in the database.
Class for iterating over a list of terms.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
#define TEST_REL(A, REL, B)
Test a relation holds,e.g. TEST_REL(a,>,b);.
ESetIterator begin() const
Return iterator pointing to the first item in this ESet.
Class for iterating over a list of terms.
ESet get_eset(Xapian::termcount maxitems, const RSet &omrset, int flags=0, const Xapian::ExpandDecider *edecider=0, double min_wt=0.0) const
Get the expand set for the given rset.
Decide if a Xapian::Error exception should be ignored.
#define TEST_NOT_EQUAL(a, b)
Test for non-equality of two things.
Xapian::doccount size() const
Return number of items in this ESet object.
Xapian::doccount get_uncollapsed_matches_estimated() const
Estimate of the total number of matching documents before collapsing.
Base class for backend handling in test harness.
string get_database_path(const string &dbname)
Class implementing a "boolean" weighting scheme.
DatabaseLockError indicates failure to lock a database.
const int DB_OPEN
Open an existing database.
This class provides read/write access to a database.
std::ostringstream tout
The debug printing stream.
Iterator over a Xapian::MSet.
Indicates an attempt to use a feature which is unavailable.
DatabaseCreateError indicates a failure to create a database.
Public interfaces for the Xapian library.
void set_sort_by_relevance_then_value(Xapian::valueno sort_key, bool reverse)
Set the sorting to be by relevance then value.
double get_maxpart() const override
Return an upper bound on what get_sumpart() can return for any document.
docids sort in ascending order (default)
#define TEST_EXCEPTION(TYPE, CODE)
Check that CODE throws exactly Xapian exception TYPE.
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.
void set_stemmer(const Xapian::Stem &stemmer)
Set the Xapian::Stem object to be used for generating stemmed terms.
Xapian::termcount get_doclength(Xapian::docid did) const
Get the length of a document.
void commit()
Commit any pending modifications made to the database.
std::string name() const override
Return the name of this weighting scheme.
Indicates an attempt to access a database not present.
TermIterator allterms_begin(const std::string &prefix=std::string()) const
An iterator which runs across all terms with a given prefix.
Iterator over a Xapian::ESet.
#define TEST_EQUAL_DOUBLE(a, b)
Test two doubles for near equality.
double get_maxextra() const override
Return an upper bound on what get_sumextra() can return for any document.
void add_database(const Database &database)
Add an existing database (or group of databases) to those accessed by this object.
void set_query(const Xapian::Query &query, Xapian::termcount qlen=0)
Set the query to run.
bool term_exists(const std::string &tname) const
Check if a given term exists in the database.
std::string get_description() const
Return a string describing this object.
Base class for matcher decision functor.
void add_document(Xapian::docid did)
Add a document to the relevance set.
#define FAIL_TEST(MSG)
Fail the current testcase with message MSG.
Xapian::Database get_database(const string &dbname)
Xapian::doccount get_matches_estimated() const
Estimate of the total number of matching documents.
MyWeight * unserialise(const string &) const override
Unserialise parameters.
const int DB_BACKEND_STUB
Open a stub database file.
#define SKIP_TEST(MSG)
Skip the current testcase with message MSG.
This class provides an interface to the information retrieval system for the purpose of searching...
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
string serialise() const override
Return this object's parameters serialised as a single string.
Xapian::termcount get_doclength() const
Return the length of the document at the current position.
Xapian::doccount get_uncollapsed_matches_upper_bound() const
Upper bound on the total number of matching documents before collapsing.
All exceptions thrown by Xapian are subclasses of Xapian::Error.
Indicates a problem communicating with a remote database.
Match documents which at least one subquery matches.
void skip_to(Xapian::docid did)
Advance the iterator to document did.
unsigned valueno
The number for a value slot in a document.
Xapian-specific test helper functions and macros.
DEFINE_TESTCASE(termstats, backend)
#define TEST_STRINGS_EQUAL(a, b)
Test for equality of two strings.
bool mset_range_is_same_weights(const Xapian::MSet &mset1, unsigned int first1, const Xapian::MSet &mset2, unsigned int first2, unsigned int count)
void keep_alive()
Send a "keep-alive" to remote databases to stop them timing out.
<unistd.h>, but with compat.
void mset_expect_order(const Xapian::MSet &A, Xapian::docid d1, Xapian::docid d2, Xapian::docid d3, Xapian::docid d4, Xapian::docid d5, Xapian::docid d6, Xapian::docid d7, Xapian::docid d8, Xapian::docid d9, Xapian::docid d10, Xapian::docid d11, Xapian::docid d12)
Class representing a list of search results.
Xapian::Document get_document() const
Get the Document object for the current position.
const int DB_CREATE_OR_OVERWRITE
Create database if it doesn't already exist, or overwrite if it does.
void set_weighting_scheme(const Weight &weight_)
Set the weighting scheme to use for queries.
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
Class representing a query.
std::string get_data() const
Get data stored in the document.
const valueno BAD_VALUENO
Reserved value to indicate "no valueno".
#define TEST_EQUAL(a, b)
Test for equality of two things.
Xapian::termcount get_unique_terms(Xapian::docid did) const
Get the number of unique terms in document.
PostingIterator postlist_end(const std::string &) const
Corresponding end iterator to postlist_begin().
Xapian::Database get_remote_database(const string &dbname, unsigned int timeout)
void set_collapse_key(Xapian::valueno collapse_key, Xapian::doccount collapse_max=1)
Set the collapse key to use for queries.
std::string get_value(Xapian::valueno slot) const
Get value by number.
ESetIterator end() const
Return iterator pointing to just after the last item in this ESet.
Xapian::doccount get_termfreq(const std::string &tname) const
Get the number of documents in the database indexed by a given term.
A handle representing a document in a Xapian database.
MyWeight * clone() const override
Clone this object.
const int DB_BACKEND_CHERT
Use the chert backend.
GrepMatchDecider(const string &needle_)
Xapian::termcount get_unique_terms() const
Return the number of unique terms in the current document.
static Xapian::Query query(const string &t)
UnimplementedError indicates an attempt to use an unimplemented feature.
PostingIterator postlist_begin(const std::string &tname) const
An iterator pointing to the start of the postlist for a given term.
void touch(const string &filename)
Touch a file, just like the Unix "touch" command.
Xapian::doccount get_uncollapsed_matches_lower_bound() const
Lower bound on the total number of matching documents before collapsing.
Abstract base class for weighting schemes.
Xapian::termcount get_collection_freq(const std::string &tname) const
Return the total number of occurrences of the given term.
docids sort in descending order.
std::string get_description() const
Return a string describing this object.