xapian-core  1.4.25
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 
283  void set_expansion_scheme(const std::string &eweightname_,
284  double expand_k_ = 1.0) const;
285 
317  void set_collapse_key(Xapian::valueno collapse_key,
318  Xapian::doccount collapse_max = 1);
319 
324  typedef enum {
326  ASCENDING = 1,
328  DESCENDING = 0,
331  DONT_CARE = 2
332  } docid_order;
333 
358  void set_docid_order(docid_order order);
359 
378  void set_cutoff(int percent_cutoff, double weight_cutoff = 0);
379 
384  void set_sort_by_relevance();
385 
399  void set_sort_by_value(Xapian::valueno sort_key, bool reverse);
400 
407  void set_sort_by_key(Xapian::KeyMaker * sorter, bool reverse);
408 
423  void set_sort_by_value_then_relevance(Xapian::valueno sort_key,
424  bool reverse);
425 
433  void set_sort_by_key_then_relevance(Xapian::KeyMaker * sorter,
434  bool reverse);
435 
462  void set_sort_by_relevance_then_value(Xapian::valueno sort_key,
463  bool reverse);
464 
485  void set_sort_by_relevance_then_key(Xapian::KeyMaker * sorter,
486  bool reverse);
487 
505  void set_time_limit(double time_limit);
506 
543  MSet get_mset(Xapian::doccount first, Xapian::doccount maxitems,
544  Xapian::doccount checkatleast = 0,
545  const RSet * omrset = 0,
546  const MatchDecider * mdecider = 0) const;
547 
579  const RSet * omrset,
580  const MatchDecider * mdecider = 0) const {
581  return get_mset(first, maxitems, 0, omrset, mdecider);
582  }
583 
593  static const int INCLUDE_QUERY_TERMS = 1;
594 
603  static const int USE_EXACT_TERMFREQ = 2;
604 
626  ESet get_eset(Xapian::termcount maxitems,
627  const RSet & omrset,
628  int flags = 0,
629  const Xapian::ExpandDecider * edecider = 0,
630  double min_wt = 0.0) const;
631 
645  ESet get_eset(Xapian::termcount maxitems, const RSet & omrset,
646  const Xapian::ExpandDecider * edecider) const {
647  return get_eset(maxitems, omrset, 0, edecider);
648  }
649 
674  XAPIAN_DEPRECATED(ESet get_eset(Xapian::termcount maxitems,
675  const RSet & rset,
676  int flags,
677  double k,
678  const Xapian::ExpandDecider * edecider = NULL,
679  double min_wt = 0.0) const) {
680  set_expansion_scheme("trad", k);
681  return get_eset(maxitems, rset, flags, edecider, min_wt);
682  }
683 
712  TermIterator get_matching_terms_begin(Xapian::docid did) const;
713 
715  TermIterator XAPIAN_NOTHROW(get_matching_terms_end(Xapian::docid /*did*/) const) {
716  return TermIterator();
717  }
718 
741  TermIterator get_matching_terms_begin(const MSetIterator &it) const;
742 
744  TermIterator XAPIAN_NOTHROW(get_matching_terms_end(const MSetIterator &/*it*/) const) {
745  return TermIterator();
746  }
747 
749  std::string get_description() const;
750 };
751 
752 }
753 
754 #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:645
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:715
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:744
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:324
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:578
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