xapian-core  1.4.27
enquire.h
Go to the documentation of this file.
1 
4 /* Copyright 1999,2000,2001 BrightStation PLC
5  * Copyright 2001,2002 Ananova Ltd
6  * Copyright 2002,2003,2004,2005,2006,2007,2008,2009,2011,2012,2013,2014,2015,2016 Olly Betts
7  * Copyright 2009 Lemur Consulting Ltd
8  * Copyright 2011 Action Without Borders
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 #ifndef XAPIAN_INCLUDED_ENQUIRE_H
27 #define XAPIAN_INCLUDED_ENQUIRE_H
28 
29 #if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD
30 # error Never use <xapian/enquire.h> directly; include <xapian.h> instead.
31 #endif
32 
33 #include "xapian/deprecated.h"
34 #include <string>
35 
36 #include <xapian/attributes.h>
37 #include <xapian/eset.h>
38 #include <xapian/intrusive_ptr.h>
39 #include <xapian/mset.h>
40 #include <xapian/stem.h>
41 #include <xapian/types.h>
42 #include <xapian/termiterator.h>
43 #include <xapian/visibility.h>
44 
45 namespace Xapian {
46 
47 class Database;
48 class Document;
49 class ErrorHandler;
50 class ExpandDecider;
51 class KeyMaker;
52 class MatchSpy;
53 class Query;
54 class Weight;
55 
61  public:
63  class Internal;
64 
67 
69  RSet(const RSet &rset);
70 
72  void operator=(const RSet &rset);
73 
74 #ifdef XAPIAN_MOVE_SEMANTICS
75  RSet(RSet && o);
77 
79  RSet & operator=(RSet && o);
80 #endif
81 
83  RSet();
84 
86  ~RSet();
87 
89  Xapian::doccount size() const;
90 
92  bool empty() const;
93 
95  void add_document(Xapian::docid did);
96 
99 
101  void remove_document(Xapian::docid did);
102 
105 
107  bool contains(Xapian::docid did) const;
108 
110  bool contains(const Xapian::MSetIterator & i) const { return contains(*i); }
111 
113  std::string get_description() const;
114 };
115 
120  void operator=(const MatchDecider &);
121 
123  MatchDecider(const MatchDecider &);
124 
125  public:
128 
136  virtual bool operator()(const Xapian::Document &doc) const = 0;
137 
139  virtual ~MatchDecider();
140 };
141 
153  public:
155  Enquire(const Enquire & other);
156 
158  void operator=(const Enquire & other);
159 
160 #ifdef XAPIAN_MOVE_SEMANTICS
161  Enquire(Enquire&& o);
163 
165  Enquire& operator=(Enquire&& o);
166 #endif
167 
168  class Internal;
171 
190  explicit Enquire(const Database &database);
191 
212  XAPIAN_DEPRECATED_EX(Enquire(const Database &database, ErrorHandler * errorhandler_));
213 
216  ~Enquire();
217 
224  void set_query(const Xapian::Query & query, Xapian::termcount qlen = 0);
225 
231  const Xapian::Query & get_query() const;
232 
255  void add_matchspy(MatchSpy * spy);
256 
259  void clear_matchspies();
260 
267  void set_weighting_scheme(const Weight &weight_);
268 
285  void set_expansion_scheme(const std::string &eweightname_,
286  double expand_k_ = 1.0) const;
287 
319  void set_collapse_key(Xapian::valueno collapse_key,
320  Xapian::doccount collapse_max = 1);
321 
326  typedef enum {
328  ASCENDING = 1,
330  DESCENDING = 0,
333  DONT_CARE = 2
334  } docid_order;
335 
360  void set_docid_order(docid_order order);
361 
380  void set_cutoff(int percent_cutoff, double weight_cutoff = 0);
381 
386  void set_sort_by_relevance();
387 
401  void set_sort_by_value(Xapian::valueno sort_key, bool reverse);
402 
409  void set_sort_by_key(Xapian::KeyMaker * sorter, bool reverse);
410 
425  void set_sort_by_value_then_relevance(Xapian::valueno sort_key,
426  bool reverse);
427 
435  void set_sort_by_key_then_relevance(Xapian::KeyMaker * sorter,
436  bool reverse);
437 
464  void set_sort_by_relevance_then_value(Xapian::valueno sort_key,
465  bool reverse);
466 
487  void set_sort_by_relevance_then_key(Xapian::KeyMaker * sorter,
488  bool reverse);
489 
507  void set_time_limit(double time_limit);
508 
545  MSet get_mset(Xapian::doccount first, Xapian::doccount maxitems,
546  Xapian::doccount checkatleast = 0,
547  const RSet * omrset = 0,
548  const MatchDecider * mdecider = 0) const;
549 
581  const RSet * omrset,
582  const MatchDecider * mdecider = 0) const {
583  return get_mset(first, maxitems, 0, omrset, mdecider);
584  }
585 
595  static const int INCLUDE_QUERY_TERMS = 1;
596 
605  static const int USE_EXACT_TERMFREQ = 2;
606 
628  ESet get_eset(Xapian::termcount maxitems,
629  const RSet & omrset,
630  int flags = 0,
631  const Xapian::ExpandDecider * edecider = 0,
632  double min_wt = 0.0) const;
633 
647  ESet get_eset(Xapian::termcount maxitems, const RSet & omrset,
648  const Xapian::ExpandDecider * edecider) const {
649  return get_eset(maxitems, omrset, 0, edecider);
650  }
651 
676  XAPIAN_DEPRECATED(ESet get_eset(Xapian::termcount maxitems,
677  const RSet & rset,
678  int flags,
679  double k,
680  const Xapian::ExpandDecider * edecider = NULL,
681  double min_wt = 0.0) const) {
682  set_expansion_scheme("trad", k);
683  return get_eset(maxitems, rset, flags, edecider, min_wt);
684  }
685 
714  TermIterator get_matching_terms_begin(Xapian::docid did) const;
715 
717  TermIterator XAPIAN_NOTHROW(get_matching_terms_end(Xapian::docid /*did*/) const) {
718  return TermIterator();
719  }
720 
743  TermIterator get_matching_terms_begin(const MSetIterator &it) const;
744 
746  TermIterator XAPIAN_NOTHROW(get_matching_terms_end(const MSetIterator &/*it*/) const) {
747  return TermIterator();
748  }
749 
751  std::string get_description() const;
752 };
753 
754 }
755 
756 #endif /* XAPIAN_INCLUDED_ENQUIRE_H */
The Xapian namespace contains public interfaces for the Xapian library.
Definition: compactor.cc:80
ESet get_eset(Xapian::termcount maxitems, const RSet &omrset, const Xapian::ExpandDecider *edecider) const
Get the expand set for the given rset.
Definition: enquire.h:647
typedefs for Xapian
This class is used to access a database, or a group of databases.
Definition: database.h:68
TermIterator get_matching_terms_end(Xapian::docid) const
End iterator corresponding to get_matching_terms_begin()
Definition: enquire.h:717
Abstract base class for match spies.
Definition: matchspy.h:49
#define XAPIAN_DEPRECATED_EX(D)
Definition: deprecated.h:38
Compiler attribute macros.
bool contains(const Xapian::MSetIterator &i) const
Test if a given document in the relevance set.
Definition: enquire.h:110
Define XAPIAN_DEPRECATED() and related macros.
Class representing a list of search results.
Definition: mset.h:44
TermIterator get_matching_terms_end(const MSetIterator &) const
End iterator corresponding to get_matching_terms_begin()
Definition: enquire.h:746
Virtual base class for expand decider functor.
Definition: expanddecider.h:37
void remove_document(const Xapian::MSetIterator &i)
Remove a document from the relevance set.
Definition: enquire.h:104
#define XAPIAN_DEPRECATED(X)
#define XAPIAN_VISIBILITY_DEFAULT
Definition: visibility.h:28
bool contains(const std::string &s, char substring)
Definition: stringutils.h:99
Class for iterating over a list of terms.
Definition: termiterator.h:41
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
Definition: types.h:72
Decide if a Xapian::Error exception should be ignored.
Definition: errorhandler.h:50
Iterator over a Xapian::MSet.
Definition: mset.h:368
Define XAPIAN_VISIBILITY_* macros.
Class representing a list of search results.
void add_document(const Xapian::MSetIterator &i)
Add a document to the relevance set.
Definition: enquire.h:98
Base class for matcher decision functor.
Definition: enquire.h:118
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
This class provides an interface to the information retrieval system for the purpose of searching...
Definition: enquire.h:152
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
Definition: types.h:38
Class representing a list of query expansion terms.
unsigned valueno
The number for a value slot in a document.
Definition: types.h:108
Class representing a list of search results.
Definition: eset.h:43
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
Definition: types.h:52
Class representing a query.
Definition: query.h:46
A smart pointer that uses intrusive reference counting.
Definition: intrusive_ptr.h:81
Class for iterating over a list of terms.
stemming algorithms
Internals of enquire system.
docid_order
Ordering of docids.
Definition: enquire.h:326
MSet get_mset(Xapian::doccount first, Xapian::doccount maxitems, const RSet *omrset, const MatchDecider *mdecider=0) const
Get (a portion of) the match set for the current query.
Definition: enquire.h:580
A handle representing a document in a Xapian database.
Definition: document.h:61
Virtual base class for key making functors.
Definition: keymaker.h:41
A relevance set (R-Set).
Definition: enquire.h:60
Abstract base class for weighting schemes.
Definition: weight.h:35
MatchDecider()
Default constructor.
Definition: enquire.h:127