xapian-core  1.4.25
api_nodb.cc
Go to the documentation of this file.
1 
4 /* Copyright 1999,2000,2001 BrightStation PLC
5  * Copyright 2002 Ananova Ltd
6  * Copyright 2002,2003,2004,2005,2006,2007,2008,2009,2010,2015,2016,2017,2019 Olly Betts
7  * Copyright 2006 Lemur Consulting Ltd
8  * Copyright (C) 2016 Vivek Pal
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License as
12  * published by the Free Software Foundation; either version 2 of the
13  * License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
23  * USA
24  */
25 
26 #include <config.h>
27 
28 #include "api_nodb.h"
29 
30 #include <xapian.h>
31 
32 #include "apitest.h"
33 #include "testsuite.h"
34 #include "testutils.h"
35 
36 #include <list>
37 #include <string>
38 #include <vector>
39 
40 using namespace std;
41 
42 // tests that get_query_terms() returns the terms in the right order
43 DEFINE_TESTCASE(getqterms1, !backend) {
44  list<string> answers_list;
45  answers_list.push_back("one");
46  answers_list.push_back("two");
47  answers_list.push_back("three");
48  answers_list.push_back("four");
49 
52  Xapian::Query("one", 1, 1),
53  Xapian::Query("three", 1, 3)),
55  Xapian::Query("four", 1, 4),
56  Xapian::Query("two", 1, 2)));
57 
58  list<string> list1;
59  {
61  for (t = myquery.get_terms_begin(); t != myquery.get_terms_end(); ++t)
62  list1.push_back(*t);
63  }
64  TEST(list1 == answers_list);
65  list<string> list2(myquery.get_terms_begin(), myquery.get_terms_end());
66  TEST(list2 == answers_list);
67 }
68 
69 // tests that get_query_terms() doesn't SEGV on an empty query
70 // (regression test for bug in 0.9.0)
71 DEFINE_TESTCASE(getqterms2, !backend) {
72  Xapian::Query empty_query;
73  TEST_EQUAL(empty_query.get_terms_begin(), empty_query.get_terms_end());
74  TEST_EQUAL(empty_query.get_unique_terms_begin(),
75  empty_query.get_unique_terms_end());
76 }
77 
78 // tests that empty queries work correctly
79 DEFINE_TESTCASE(emptyquery2, !backend) {
80  // test that Query::empty() is true for an empty query.
81  TEST(Xapian::Query().empty());
82  // test that an empty query has length 0
83  TEST(Xapian::Query().get_length() == 0);
84  vector<Xapian::Query> v;
85  TEST(Xapian::Query(Xapian::Query::OP_OR, v.begin(), v.end()).empty());
86  TEST(Xapian::Query(Xapian::Query::OP_OR, v.begin(), v.end()).get_length() == 0);
87 }
88 
90 DEFINE_TESTCASE(emptyquery3, !backend) {
91  static const Xapian::Query::op ops[] = {
97  };
98 
99  for (size_t i = 0; i < sizeof(ops) / sizeof(ops[0]); ++i) {
100  tout << "Testing op #" << i << '\n';
101  Xapian::Query empty;
102  Xapian::Query q("test");
103  Xapian::Query qcombine(ops[i], empty, q);
104  tout << qcombine.get_description() << '\n';
105  Xapian::Query qcombine2(ops[i], q, empty);
106  tout << qcombine2.get_description() << '\n';
107  Xapian::Query qcombine3(ops[i], empty, empty);
108  tout << qcombine3.get_description() << '\n';
109  }
110 }
111 
112 // tests that query lengths are calculated correctly
113 DEFINE_TESTCASE(querylen1, !backend) {
114  // test that a simple query has the right length
115  Xapian::Query myquery;
117  Xapian::Query("foo"),
118  Xapian::Query("bar"));
120  myquery,
122  Xapian::Query("wibble"),
123  Xapian::Query("spoon")));
124 
125  TEST_EQUAL(myquery.get_length(), 4);
126  TEST(!myquery.empty());
127 }
128 
129 // tests that query lengths are calculated correctly
130 DEFINE_TESTCASE(querylen2, !backend) {
131  // test with an even bigger and strange query
132  string terms[3] = {
133  "foo",
134  "bar",
135  "baz"
136  };
137  Xapian::Query queries[3] = {
138  Xapian::Query("wibble"),
139  Xapian::Query("wobble"),
140  Xapian::Query(Xapian::Query::OP_OR, string("jelly"), string("belly"))
141  };
142 
143  Xapian::Query myquery;
144  vector<string> v1(terms, terms + 3);
145  vector<Xapian::Query> v2(queries, queries + 3);
146  vector<Xapian::Query *> v3;
147  Xapian::Query query1(Xapian::Query::OP_AND, string("ball"), string("club"));
148  Xapian::Query query2("ring");
149  v3.push_back(&query1);
150  v3.push_back(&query2);
151 
152  Xapian::Query myq1 = Xapian::Query(Xapian::Query::OP_AND, v1.begin(), v1.end());
153  tout << "myq1=" << myq1 << "\n";
154  TEST_EQUAL(myq1.get_length(), 3);
155 
156  Xapian::Query myq2_1 = Xapian::Query(Xapian::Query::OP_OR, v2.begin(), v2.end());
157  tout << "myq2_1=" << myq2_1 << "\n";
158  TEST_EQUAL(myq2_1.get_length(), 4);
159 
160  Xapian::Query myq2_2 = Xapian::Query(Xapian::Query::OP_AND, v3.begin(), v3.end());
161  tout << "myq2_2=" << myq2_2 << "\n";
162  TEST_EQUAL(myq2_2.get_length(), 3);
163 
164  Xapian::Query myq2 = Xapian::Query(Xapian::Query::OP_OR, myq2_1, myq2_2);
165  tout << "myq2=" << myq2 << "\n";
166  TEST_EQUAL(myq2.get_length(), 7);
167 
168  myquery = Xapian::Query(Xapian::Query::OP_OR, myq1, myq2);
169  tout << "myquery=" << myquery << "\n";
170  TEST_EQUAL(myquery.get_length(), 10);
171 }
172 
179 DEFINE_TESTCASE(dontflattensubqueries1, !backend) {
180  Xapian::Query queries1[3] = {
181  Xapian::Query("wibble"),
182  Xapian::Query("wobble"),
183  Xapian::Query(Xapian::Query::OP_OR, string("jelly"), string("belly"))
184  };
185 
186  Xapian::Query queries2[3] = {
187  Xapian::Query(Xapian::Query::OP_AND, string("jelly"), string("belly")),
188  Xapian::Query("wibble"),
189  Xapian::Query("wobble")
190  };
191 
192  vector<Xapian::Query> vec1(queries1, queries1 + 3);
193  Xapian::Query myquery1(Xapian::Query::OP_OR, vec1.begin(), vec1.end());
194  TEST_EQUAL(myquery1.get_description(),
195  "Query((wibble OR wobble OR (jelly OR belly)))");
196 
197  vector<Xapian::Query> vec2(queries2, queries2 + 3);
198  Xapian::Query myquery2(Xapian::Query::OP_AND, vec2.begin(), vec2.end());
199  TEST_EQUAL(myquery2.get_description(),
200  "Query(((jelly AND belly) AND wibble AND wobble))");
201 }
202 
203 // test behaviour when creating a query from an empty vector
204 DEFINE_TESTCASE(emptyquerypart1, !backend) {
205  vector<string> emptyterms;
206  Xapian::Query query(Xapian::Query::OP_OR, emptyterms.begin(), emptyterms.end());
208  TEST(Xapian::Query(Xapian::Query::OP_AND, query, Xapian::Query("x")).get_length() == 0);
210  TEST(Xapian::Query(Xapian::Query::OP_OR, query, Xapian::Query("x")).get_length() == 1);
211 }
212 
213 DEFINE_TESTCASE(stemlangs1, !backend) {
214  string langs = Xapian::Stem::get_available_languages();
215  tout << "available languages '" << langs << "'\n";
216  TEST(!langs.empty());
217 
218  // Also test the language codes.
219  langs += " ar hy eu ca da nl en fi fr de hu id ga it lt ne nb nn no pt ro"
220  " ru es sv ta tr";
221 
222  string::size_type i = 0;
223  while (true) {
224  string::size_type spc = langs.find(' ', i);
225  // The only spaces in langs should be a single one between each pair
226  // of language names.
227  TEST_NOT_EQUAL(i, spc);
228 
229  // Try making a stemmer for this language. We should be able to create
230  // it without an exception being thrown.
231  string language(langs, i, spc - i);
232  tout << "checking language code '" << language << "' works\n";
233  Xapian::Stem stemmer(language);
234  TEST(!stemmer.is_none());
235  if (language.size() > 2) {
236  string expected("Xapian::Stem(");
237  expected += language;
238  expected += ')';
239  TEST_EQUAL(stemmer.get_description(), expected);
240  }
241 
242  if (spc == string::npos) break;
243  i = spc + 1;
244  }
245 
246  {
247  // Stem("none") should give a no-op stemmer.
248  Xapian::Stem stem_nothing = Xapian::Stem("none");
249  TEST(stem_nothing.is_none());
250  TEST_EQUAL(stem_nothing.get_description(), "Xapian::Stem(none)");
251  }
252 
253  {
254  // Stem("") should be equivalent.
255  Xapian::Stem stem_nothing = Xapian::Stem("");
256  TEST(stem_nothing.is_none());
257  TEST_EQUAL(stem_nothing.get_description(), "Xapian::Stem(none)");
258  }
259 }
260 
261 // Some simple tests of the built in weighting schemes.
262 DEFINE_TESTCASE(weight1, !backend) {
263  Xapian::Weight * wt;
264 
265  Xapian::BoolWeight boolweight;
266  TEST_EQUAL(boolweight.name(), "Xapian::BoolWeight");
267  wt = Xapian::BoolWeight().unserialise(boolweight.serialise());
268  TEST_EQUAL(boolweight.serialise(), wt->serialise());
269  delete wt;
270 
271  Xapian::CoordWeight coordweight;
272  TEST_EQUAL(coordweight.name(), "Xapian::CoordWeight");
273  wt = Xapian::CoordWeight().unserialise(coordweight.serialise());
274  TEST_EQUAL(coordweight.serialise(), wt->serialise());
275  delete wt;
276 
277  Xapian::TradWeight tradweight_dflt;
278  Xapian::TradWeight tradweight(1.0);
279  TEST_EQUAL(tradweight.name(), "Xapian::TradWeight");
280  TEST_EQUAL(tradweight_dflt.serialise(), tradweight.serialise());
281  wt = Xapian::TradWeight().unserialise(tradweight.serialise());
282  TEST_EQUAL(tradweight.serialise(), wt->serialise());
283  delete wt;
284 
285  Xapian::TradWeight tradweight2(2.0);
286  TEST_NOT_EQUAL(tradweight.serialise(), tradweight2.serialise());
287 
288  Xapian::BM25Weight bm25weight_dflt;
289  Xapian::BM25Weight bm25weight(1, 0, 1, 0.5, 0.5);
290  TEST_EQUAL(bm25weight.name(), "Xapian::BM25Weight");
291  TEST_EQUAL(bm25weight_dflt.serialise(), bm25weight.serialise());
292  wt = Xapian::BM25Weight().unserialise(bm25weight.serialise());
293  TEST_EQUAL(bm25weight.serialise(), wt->serialise());
294  delete wt;
295 
296  Xapian::BM25Weight bm25weight2(1, 0.5, 1, 0.5, 0.5);
297  TEST_NOT_EQUAL(bm25weight.serialise(), bm25weight2.serialise());
298 
299  Xapian::BM25PlusWeight bm25plusweight_dflt;
300  Xapian::BM25PlusWeight bm25plusweight(1, 0, 1, 0.5, 0.5, 1.0);
301  TEST_EQUAL(bm25plusweight.name(), "Xapian::BM25PlusWeight");
302  TEST_EQUAL(bm25plusweight_dflt.serialise(), bm25plusweight.serialise());
303  wt = Xapian::BM25PlusWeight().unserialise(bm25plusweight.serialise());
304  TEST_EQUAL(bm25plusweight.serialise(), wt->serialise());
305  delete wt;
306 
307  Xapian::BM25PlusWeight bm25plusweight2(1, 0, 1, 0.5, 0.5, 2.0);
308  TEST_NOT_EQUAL(bm25plusweight.serialise(), bm25plusweight2.serialise());
309 
310  Xapian::TfIdfWeight tfidfweight_dflt;
311  Xapian::TfIdfWeight tfidfweight("ntn");
312  TEST_EQUAL(tfidfweight.name(), "Xapian::TfIdfWeight");
313  TEST_EQUAL(tfidfweight_dflt.serialise(), tfidfweight.serialise());
314  wt = Xapian::TfIdfWeight().unserialise(tfidfweight.serialise());
315  TEST_EQUAL(tfidfweight.serialise(), wt->serialise());
316  delete wt;
317 
318  Xapian::TfIdfWeight tfidfweight2("bpn");
319  TEST_NOT_EQUAL(tfidfweight.serialise(), tfidfweight2.serialise());
320 
321  Xapian::InL2Weight inl2weight_dflt;
322  Xapian::InL2Weight inl2weight(1.0);
323  TEST_EQUAL(inl2weight.name(), "Xapian::InL2Weight");
324  TEST_EQUAL(inl2weight_dflt.serialise(), inl2weight.serialise());
325  wt = Xapian::InL2Weight().unserialise(inl2weight.serialise());
326  TEST_EQUAL(inl2weight.serialise(), wt->serialise());
327  delete wt;
328 
329  Xapian::InL2Weight inl2weight2(2.0);
330  TEST_NOT_EQUAL(inl2weight.serialise(), inl2weight2.serialise());
331 
332  Xapian::IfB2Weight ifb2weight_dflt;
333  Xapian::IfB2Weight ifb2weight(1.0);
334  TEST_EQUAL(ifb2weight.name(), "Xapian::IfB2Weight");
335  TEST_EQUAL(ifb2weight_dflt.serialise(), ifb2weight.serialise());
336  wt = Xapian::IfB2Weight().unserialise(ifb2weight.serialise());
337  TEST_EQUAL(ifb2weight.serialise(), wt->serialise());
338  delete wt;
339 
340  Xapian::IfB2Weight ifb2weight2(2.0);
341  TEST_NOT_EQUAL(ifb2weight.serialise(), ifb2weight2.serialise());
342 
343  Xapian::IneB2Weight ineb2weight_dflt;
344  Xapian::IneB2Weight ineb2weight(1.0);
345  TEST_EQUAL(ineb2weight.name(), "Xapian::IneB2Weight");
346  TEST_EQUAL(ineb2weight_dflt.serialise(), ineb2weight.serialise());
347  wt = Xapian::IneB2Weight().unserialise(ineb2weight.serialise());
348  TEST_EQUAL(ineb2weight.serialise(), wt->serialise());
349  delete wt;
350 
351  Xapian::IneB2Weight ineb2weight2(2.0);
352  TEST_NOT_EQUAL(ineb2weight.serialise(), ineb2weight2.serialise());
353 
354  Xapian::BB2Weight bb2weight_dflt;
355  Xapian::BB2Weight bb2weight(1.0);
356  TEST_EQUAL(bb2weight.name(), "Xapian::BB2Weight");
357  TEST_EQUAL(bb2weight_dflt.serialise(), bb2weight.serialise());
358  wt = Xapian::BB2Weight().unserialise(bb2weight.serialise());
359  TEST_EQUAL(bb2weight.serialise(), wt->serialise());
360  delete wt;
361 
362  Xapian::BB2Weight bb2weight2(2.0);
363  TEST_NOT_EQUAL(bb2weight.serialise(), bb2weight2.serialise());
364 
365  Xapian::DLHWeight dlhweight;
366  TEST_EQUAL(dlhweight.name(), "Xapian::DLHWeight");
367  wt = Xapian::DLHWeight().unserialise(dlhweight.serialise());
368  TEST_EQUAL(dlhweight.serialise(), wt->serialise());
369  delete wt;
370 
371  Xapian::PL2Weight pl2weight_dflt;
372  Xapian::PL2Weight pl2weight(1.0);
373  TEST_EQUAL(pl2weight.name(), "Xapian::PL2Weight");
374  TEST_EQUAL(pl2weight_dflt.serialise(), pl2weight.serialise());
375  wt = Xapian::PL2Weight().unserialise(pl2weight.serialise());
376  TEST_EQUAL(pl2weight.serialise(), wt->serialise());
377  delete wt;
378 
379  Xapian::PL2Weight pl2weight2(2.0);
380  TEST_NOT_EQUAL(pl2weight.serialise(), pl2weight2.serialise());
381 
382  Xapian::PL2PlusWeight pl2plusweight_dflt;
383  Xapian::PL2PlusWeight pl2plusweight(1.0, 0.8);
384  TEST_EQUAL(pl2plusweight.name(), "Xapian::PL2PlusWeight");
385  TEST_EQUAL(pl2plusweight_dflt.serialise(), pl2plusweight.serialise());
386  wt = Xapian::PL2PlusWeight().unserialise(pl2plusweight.serialise());
387  TEST_EQUAL(pl2plusweight.serialise(), wt->serialise());
388  delete wt;
389 
390  Xapian::PL2PlusWeight pl2plusweight2(2.0, 0.9);
391  TEST_NOT_EQUAL(pl2plusweight.serialise(), pl2plusweight2.serialise());
392 
393  Xapian::DPHWeight dphweight;
394  TEST_EQUAL(dphweight.name(), "Xapian::DPHWeight");
395  wt = Xapian::DPHWeight().unserialise(dphweight.serialise());
396  TEST_EQUAL(dphweight.serialise(), wt->serialise());
397  delete wt;
398 
399  Xapian::LMWeight unigramlmweight_dflt;
400  Xapian::LMWeight unigramlmweight(32000, Xapian::Weight::DIRICHLET_SMOOTHING, 2034.0, 0.0);
401  TEST_EQUAL(unigramlmweight.name(), "Xapian::LMWeight");
402  TEST_NOT_EQUAL(unigramlmweight_dflt.serialise(), unigramlmweight.serialise());
403  wt = Xapian::LMWeight().unserialise(unigramlmweight.serialise());
404  TEST_EQUAL(unigramlmweight.serialise(), wt->serialise());
405  delete wt;
406 }
407 
408 // Regression test.
409 DEFINE_TESTCASE(nosuchdb1, !backend) {
410  // This is a "nodb" test because it doesn't test a particular backend.
411  try {
412  Xapian::Database db("NOsuChdaTabASe");
413  FAIL_TEST("Managed to open 'NOsuChdaTabASe'");
414  } catch (const Xapian::DatabaseOpeningError & e) {
415  // We don't really require this exact message, but in Xapian <= 1.1.0
416  // this gave "Couldn't detect type of database".
417  TEST_STRINGS_EQUAL(e.get_msg(), "Couldn't stat 'NOsuChdaTabASe'");
418  }
419 
420  try {
421  Xapian::Database::check("NOsuChdaTabASe");
422  FAIL_TEST("Managed to check 'NOsuChdaTabASe'");
423  } catch (const Xapian::DatabaseOpeningError & e) {
424  // In 1.4.3 and earlier, this threw DatabaseError with the message:
425  // "File is not a Xapian database or database table" (confusing as
426  // there is no file).
428  "Couldn't find Xapian database or table to check");
429  }
430 }
431 
432 // Feature tests for value manipulations.
433 DEFINE_TESTCASE(addvalue1, !backend) {
434  // Regression test for add_value on an existing value (bug#82).
435  Xapian::Document doc;
436  doc.add_value(1, "original");
437  doc.add_value(1, "replacement");
438  TEST_EQUAL(doc.get_value(1), "replacement");
439 
440  doc.add_value(2, "too");
441  doc.add_value(3, "free");
442  doc.add_value(4, "for");
443 
444  doc.remove_value(2);
445  doc.remove_value(4);
446  TEST_EQUAL(doc.get_value(0), "");
447  TEST_EQUAL(doc.get_value(1), "replacement");
448  TEST_EQUAL(doc.get_value(2), "");
449  TEST_EQUAL(doc.get_value(3), "free");
450  TEST_EQUAL(doc.get_value(4), "");
451 }
452 
453 // tests that the collapsing on termpos optimisation gives correct query length
454 DEFINE_TESTCASE(poscollapse2, !backend) {
455  Xapian::Query q(Xapian::Query::OP_OR, Xapian::Query("this", 1, 1), Xapian::Query("this", 1, 1));
456  TEST_EQUAL(q.get_length(), 2);
457 }
458 
459 // regression test of querying an uninitialised database: should report an
460 // error; used to segfault with 1.0.0.
461 DEFINE_TESTCASE(uninitdb1, !backend) {
462  Xapian::Database db;
464  Xapian::Enquire enq(db));
465 }
466 
467 // Test a scaleweight query applied to a match nothing query
468 DEFINE_TESTCASE(scaleweight3, !backend) {
471  TEST_EQUAL(query.get_description(), "Query()");
472 }
473 
474 // Regression test - before 1.1.0, you could add docid 0 to an RSet.
475 DEFINE_TESTCASE(rset3, !backend) {
476  Xapian::RSet rset;
478  TEST(rset.empty());
479  TEST_EQUAL(rset.size(), 0);
480  rset.add_document(1);
481  rset.add_document(static_cast<Xapian::docid>(-1));
483  TEST(!rset.empty());
484  TEST_EQUAL(rset.size(), 2);
485 }
486 
487 // Regression test - RSet::get_description() gave a malformed answer in 1.0.7.
488 DEFINE_TESTCASE(rset4, !backend) {
489  Xapian::RSet rset;
490  rset.add_document(1);
491  // In 1.0.7 this gave: RSet(RSet(RSet::Internal(, 1))
492  TEST_STRINGS_EQUAL(rset.get_description(), "RSet(RSet::Internal(1))");
493 }
494 
495 // Direct test of ValueSetMatchDecider
496 DEFINE_TESTCASE(valuesetmatchdecider1, !backend) {
497  Xapian::ValueSetMatchDecider vsmd1(0, true);
498  vsmd1.add_value("42");
499  Xapian::ValueSetMatchDecider vsmd2(0, false);
500  vsmd2.remove_value("nosuch"); // Test removing a value which isn't present.
501  vsmd2.add_value("42");
502  Xapian::ValueSetMatchDecider vsmd3(0, true);
503  vsmd3.add_value("42");
504  vsmd3.add_value("blah");
505 
506  Xapian::Document doc;
507  TEST(!vsmd1(doc));
508  TEST(vsmd2(doc));
509  TEST(!vsmd3(doc));
510  doc.add_value(0, "42");
511  TEST(vsmd1(doc));
512  TEST(!vsmd2(doc));
513  TEST(vsmd3(doc));
514  doc.add_value(0, "blah");
515  TEST(!vsmd1(doc));
516  TEST(vsmd2(doc));
517  TEST(vsmd3(doc));
518 
519  vsmd3.remove_value("nosuch"); // Test removing a value which isn't present.
520  vsmd3.remove_value("blah");
521  TEST(!vsmd1(doc));
522  TEST(vsmd2(doc));
523  TEST(!vsmd3(doc));
524  doc.add_value(0, "42");
525  TEST(vsmd1(doc));
526  TEST(!vsmd2(doc));
527  TEST(vsmd3(doc));
528 }
529 
530 // Test that asking for the termfreq on an empty mset raises an exception.
531 DEFINE_TESTCASE(emptymset1, !backend) {
532  Xapian::MSet emptymset;
534  emptymset.get_termfreq("foo"));
535 }
536 
537 DEFINE_TESTCASE(expanddeciderfilterprefix1, !backend) {
538  string prefix = "tw";
539  Xapian::ExpandDeciderFilterPrefix decider(prefix);
540  TEST(!decider("one"));
541  TEST(!decider("t"));
542  TEST(!decider(""));
543  TEST(!decider("Two"));
544  TEST(decider("two"));
545  TEST(decider("twitter"));
546  TEST(decider(prefix));
547 }
const TermIterator get_unique_terms_end() const
End iterator for unique terms in the query object.
Definition: query.h:516
Xapian::termcount get_length() const
Return the length of this query object.
Definition: query.cc:187
bool is_none() const
Return true if this is a no-op stemmer.
Definition: stem.h:166
ExpandDecider subclass which restrict terms to a particular prefix.
Xapian::doccount size() const
The number of documents in this R-Set.
Definition: omenquire.cc:92
void add_value(Xapian::valueno slot, const std::string &value)
Add a new value.
Definition: omdocument.cc:107
MatchDecider filtering results based on whether document values are in a user-defined set...
static size_t check(const std::string &path, int opts=0, std::ostream *out=NULL)
Check the integrity of a database or database table.
Definition: database.h:564
#define TEST(a)
Test a condition, without an additional explanation for failure.
Definition: testsuite.h:275
std::string get_description() const
Return a string describing this object.
Definition: omenquire.cc:123
This class is used to access a database, or a group of databases.
Definition: database.h:68
Match documents which an odd number of subqueries match.
Definition: query.h:107
std::string serialise() const
Return this object&#39;s parameters serialised as a single string.
Definition: tradweight.cc:133
InvalidOperationError indicates the API was used in an invalid way.
Definition: error.h:283
const TermIterator get_terms_begin() const
Begin iterator for terms in the query object.
Definition: query.cc:135
InL2Weight * unserialise(const std::string &serialised) const
Unserialise parameters.
Definition: inl2weight.cc:103
DatabaseOpeningError indicates failure to open a database.
Definition: error.h:581
Class representing a stemming algorithm.
Definition: stem.h:62
op
Query operators.
Definition: query.h:78
PL2PlusWeight * unserialise(const std::string &serialised) const
Unserialise parameters.
void remove_value(const std::string &value)
Remove a value from the test set.
std::string serialise() const
Return this object&#39;s parameters serialised as a single string.
const std::string & get_msg() const
Message giving details of the error, intended for human consumption.
Definition: error.h:122
a generic test suite engine
void add_value(const std::string &value)
Add a value to the test set.
Class representing a list of search results.
Definition: mset.h:44
This class implements the InL2 weighting scheme.
Definition: weight.h:833
STL namespace.
std::string serialise() const
Return this object&#39;s parameters serialised as a single string.
std::string serialise() const
Return this object&#39;s parameters serialised as a single string.
Definition: inl2weight.cc:97
std::string serialise() const
Return this object&#39;s parameters serialised as a single string.
Definition: bb2weight.cc:126
BM25PlusWeight * unserialise(const std::string &serialised) const
Unserialise parameters.
Xapian::Weight subclass implementing the PL2+ probabilistic formula.
Definition: weight.h:1252
static Xapian::Stem stemmer
Definition: stemtest.cc:41
DEFINE_TESTCASE(getqterms1, !backend)
Definition: api_nodb.cc:43
std::string serialise() const
Return this object&#39;s parameters serialised as a single string.
Definition: ineb2weight.cc:99
std::string serialise() const
Return this object&#39;s parameters serialised as a single string.
Definition: tfidfweight.cc:86
void remove_value(Xapian::valueno slot)
Remove any value with the given number.
Definition: omdocument.cc:114
const TermIterator get_unique_terms_begin() const
Begin iterator for unique terms in the query object.
Definition: query.cc:160
test functionality of the Xapian API
std::string name() const
Return the name of this weighting scheme.
Definition: boolweight.cc:44
std::string name() const
Return the name of this weighting scheme.
Definition: bm25weight.cc:132
std::string name() const
Return the name of this weighting scheme.
This class implements the BB2 weighting scheme.
Definition: weight.h:1049
Class for iterating over a list of terms.
Definition: termiterator.h:41
#define TEST_NOT_EQUAL(a, b)
Test for non-equality of two things.
Definition: testsuite.h:305
IfB2Weight * unserialise(const std::string &serialised) const
Unserialise parameters.
Definition: ifb2weight.cc:106
Xapian::Weight subclass implementing Coordinate Matching.
Definition: weight.h:1504
BM25Weight * unserialise(const std::string &serialised) const
Unserialise parameters.
Definition: bm25weight.cc:149
InvalidArgumentError indicates an invalid parameter value was passed to the API.
Definition: error.h:241
std::string name() const
Return the name of this weighting scheme.
TfIdfWeight * unserialise(const std::string &serialised) const
Unserialise parameters.
Definition: tfidfweight.cc:92
Class implementing a "boolean" weighting scheme.
Definition: weight.h:422
std::ostringstream tout
The debug printing stream.
Definition: testsuite.cc:103
Scale the weight contributed by a subquery.
Definition: query.h:166
Match the first subquery taking extra weight from other subqueries.
Definition: query.h:118
std::string get_description() const
Return a string describing this object.
Definition: stem.cc:147
Public interfaces for the Xapian library.
std::string serialise() const
Return this object&#39;s parameters serialised as a single string.
Definition: lmweight.cc:100
static std::string get_available_languages()
Return a list of available languages.
Definition: stem.h:181
DPHWeight * unserialise(const std::string &serialised) const
Unserialise parameters.
Definition: dphweight.cc:129
#define TEST_EXCEPTION(TYPE, CODE)
Check that CODE throws exactly Xapian exception TYPE.
Definition: testutils.h:109
std::string name() const
Return the name of this weighting scheme.
Definition: lmweight.cc:94
IneB2Weight * unserialise(const std::string &serialised) const
Unserialise parameters.
Definition: ineb2weight.cc:105
std::string name() const
Return the name of this weighting scheme.
Definition: ifb2weight.cc:94
std::string name() const
Return the name of this weighting scheme.
Definition: inl2weight.cc:91
Xapian::Weight subclass implementing the traditional probabilistic formula.
Definition: weight.h:763
std::string serialise() const
Return this object&#39;s parameters serialised as a single string.
Definition: pl2weight.cc:138
This class implements the DLH weighting scheme, which is a representative scheme of the Divergence fr...
Definition: weight.h:1125
std::string name() const
Return the name of this weighting scheme.
Definition: pl2weight.cc:132
This class implements the PL2 weighting scheme.
Definition: weight.h:1185
This class implements the IneB2 weighting scheme.
Definition: weight.h:977
BoolWeight * unserialise(const std::string &serialised) const
Unserialise parameters.
Definition: boolweight.cc:57
std::string name() const
Return the name of this weighting scheme.
Definition: tradweight.cc:127
std::string serialise() const
Return this object&#39;s parameters serialised as a single string.
Definition: ifb2weight.cc:100
std::string serialise() const
Return this object&#39;s parameters serialised as a single string.
Definition: coordweight.cc:50
void add_document(Xapian::docid did)
Add a document to the relevance set.
Definition: omenquire.cc:104
This class implements the IfB2 weighting scheme.
Definition: weight.h:904
#define FAIL_TEST(MSG)
Fail the current testcase with message MSG.
Definition: testsuite.h:68
Match only documents which all subqueries match.
Definition: query.h:84
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())
Definition: api_anydb.cc:63
std::string name() const
Return the name of this weighting scheme.
Definition: bb2weight.cc:120
std::string get_description() const
Return a string describing this object.
Definition: query.cc:232
This class provides an interface to the information retrieval system for the purpose of searching...
Definition: enquire.h:152
CoordWeight * unserialise(const std::string &serialised) const
Unserialise parameters.
Definition: coordweight.cc:57
std::string serialise() const
Return this object&#39;s parameters serialised as a single string.
Definition: bm25weight.cc:138
PL2Weight * unserialise(const std::string &serialised) const
Unserialise parameters.
Definition: pl2weight.cc:144
This class implements the DPH weighting scheme.
Definition: weight.h:1348
bool empty() const
Check if this query is Xapian::Query::MatchNothing.
Definition: query.h:524
Match documents which the first subquery matches but no others do.
Definition: query.h:99
Match documents which at least one subquery matches.
Definition: query.h:92
Xapian-specific test helper functions and macros.
std::string name() const
Return the name of this weighting scheme.
Definition: ineb2weight.cc:93
static const Xapian::Query MatchNothing
A query matching no documents.
Definition: query.h:65
LMWeight * unserialise(const std::string &serialised) const
Unserialise parameters.
Definition: lmweight.cc:110
#define TEST_STRINGS_EQUAL(a, b)
Test for equality of two strings.
Definition: testsuite.h:287
static string language
Definition: stemtest.cc:39
Xapian::doccount get_termfreq(const std::string &term) const
Get the termfreq of a term.
Definition: omenquire.cc:206
std::string name() const
Return the name of this weighting scheme.
Definition: coordweight.cc:44
Class representing a query.
Definition: query.h:46
#define TEST_EQUAL(a, b)
Test for equality of two things.
Definition: testsuite.h:278
bool empty() const
Test if this R-Set is empty.
Definition: omenquire.cc:98
Xapian::Weight subclass implementing the Language Model formula.
Definition: weight.h:1401
const TermIterator get_terms_end() const
End iterator for terms in the query object.
Definition: query.h:502
BB2Weight * unserialise(const std::string &serialised) const
Unserialise parameters.
Definition: bb2weight.cc:132
std::string serialise() const
Return this object&#39;s parameters serialised as a single string.
Definition: boolweight.cc:50
std::string get_value(Xapian::valueno slot) const
Get value by number.
Definition: omdocument.cc:64
A handle representing a document in a Xapian database.
Definition: document.h:61
Xapian::Weight subclass implementing the BM25+ probabilistic formula.
Definition: weight.h:639
std::string name() const
Return the name of this weighting scheme.
Definition: tfidfweight.cc:80
Xapian::Weight subclass implementing the BM25 probabilistic formula.
Definition: weight.h:535
A relevance set (R-Set).
Definition: enquire.h:60
Xapian::Weight subclass implementing the tf-idf weighting scheme.
Definition: weight.h:447
Abstract base class for weighting schemes.
Definition: weight.h:35
TradWeight * unserialise(const std::string &serialised) const
Unserialise parameters.
Definition: tradweight.cc:139
DLHWeight * unserialise(const std::string &serialised) const
Unserialise parameters.
Definition: dlhweight.cc:172