xapian-core  1.4.19
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 
253  void add_matchspy(MatchSpy * spy);
254 
257  void clear_matchspies();
258 
265  void set_weighting_scheme(const Weight &weight_);
266 
281  void set_expansion_scheme(const std::string &eweightname_,
282  double expand_k_ = 1.0) const;
283 
315  void set_collapse_key(Xapian::valueno collapse_key,
316  Xapian::doccount collapse_max = 1);
317 
322  typedef enum {
324  ASCENDING = 1,
326  DESCENDING = 0,
329  DONT_CARE = 2
330  } docid_order;
331 
356  void set_docid_order(docid_order order);
357 
376  void set_cutoff(int percent_cutoff, double weight_cutoff = 0);
377 
382  void set_sort_by_relevance();
383 
397  void set_sort_by_value(Xapian::valueno sort_key, bool reverse);
398 
405  void set_sort_by_key(Xapian::KeyMaker * sorter, bool reverse);
406 
421  void set_sort_by_value_then_relevance(Xapian::valueno sort_key,
422  bool reverse);
423 
431  void set_sort_by_key_then_relevance(Xapian::KeyMaker * sorter,
432  bool reverse);
433 
460  void set_sort_by_relevance_then_value(Xapian::valueno sort_key,
461  bool reverse);
462 
483  void set_sort_by_relevance_then_key(Xapian::KeyMaker * sorter,
484  bool reverse);
485 
503  void set_time_limit(double time_limit);
504 
541  MSet get_mset(Xapian::doccount first, Xapian::doccount maxitems,
542  Xapian::doccount checkatleast = 0,
543  const RSet * omrset = 0,
544  const MatchDecider * mdecider = 0) const;
545 
577  const RSet * omrset,
578  const MatchDecider * mdecider = 0) const {
579  return get_mset(first, maxitems, 0, omrset, mdecider);
580  }
581 
591  static const int INCLUDE_QUERY_TERMS = 1;
592 
601  static const int USE_EXACT_TERMFREQ = 2;
602 
624  ESet get_eset(Xapian::termcount maxitems,
625  const RSet & omrset,
626  int flags = 0,
627  const Xapian::ExpandDecider * edecider = 0,
628  double min_wt = 0.0) const;
629 
643  ESet get_eset(Xapian::termcount maxitems, const RSet & omrset,
644  const Xapian::ExpandDecider * edecider) const {
645  return get_eset(maxitems, omrset, 0, edecider);
646  }
647 
672  XAPIAN_DEPRECATED(ESet get_eset(Xapian::termcount maxitems,
673  const RSet & rset,
674  int flags,
675  double k,
676  const Xapian::ExpandDecider * edecider = NULL,
677  double min_wt = 0.0) const) {
678  set_expansion_scheme("trad", k);
679  return get_eset(maxitems, rset, flags, edecider, min_wt);
680  }
681 
710  TermIterator get_matching_terms_begin(Xapian::docid did) const;
711 
713  TermIterator XAPIAN_NOTHROW(get_matching_terms_end(Xapian::docid /*did*/) const) {
714  return TermIterator();
715  }
716 
739  TermIterator get_matching_terms_begin(const MSetIterator &it) const;
740 
742  TermIterator XAPIAN_NOTHROW(get_matching_terms_end(const MSetIterator &/*it*/) const) {
743  return TermIterator();
744  }
745 
747  std::string get_description() const;
748 };
749 
750 }
751 
752 #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:643
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:713
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:742
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
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:351
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:322
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:576
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