xapian-core  2.0.0
enquire.h
Go to the documentation of this file.
1 
4 /* Copyright (C) 2005,2013,2016,2017,2024 Olly Betts
5  * Copyright (C) 2009 Lemur Consulting Ltd
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License as
9  * published by the Free Software Foundation; either version 2 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, see
19  * <https://www.gnu.org/licenses/>.
20  */
21 
22 #ifndef XAPIAN_INCLUDED_ENQUIRE_H
23 #define XAPIAN_INCLUDED_ENQUIRE_H
24 
25 #if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD
26 # error Never use <xapian/enquire.h> directly; include <xapian.h> instead.
27 #endif
28 
29 #include <string>
30 
31 #include <xapian/attributes.h>
32 #include <xapian/eset.h>
33 #include <xapian/intrusive_ptr.h>
34 #include <xapian/mset.h>
35 #include <xapian/types.h>
36 #include <xapian/termiterator.h>
37 #include <xapian/visibility.h>
38 
39 namespace Xapian {
40 
41 // Forward declarations of classes referenced below.
42 class Database;
43 class ExpandDecider;
44 class KeyMaker;
45 class MatchDecider;
46 class MatchSpy;
47 class Query;
48 class RSet;
49 class Weight;
50 
58  public:
60  class Internal;
63 
68  Enquire(const Enquire& o);
69 
75 
78 
81 
90  explicit
91  Enquire(const Database& db);
92 
94  ~Enquire();
95 
105  void set_query(const Query& query, termcount query_length = 0);
106 
112  const Query& get_query() const;
113 
124  void set_weighting_scheme(const Weight& weight);
125 
130  typedef enum {
132  ASCENDING = 1,
134  DESCENDING = 0,
136  DONT_CARE = 2
137  } docid_order;
138 
163  void set_docid_order(docid_order order);
164 
169  void set_sort_by_relevance();
170 
184  void set_sort_by_value(valueno sort_key, bool reverse);
185 
192  void set_sort_by_key(KeyMaker* sorter,
193  bool reverse) XAPIAN_NONNULL();
194 
209  void set_sort_by_value_then_relevance(valueno sort_key, bool reverse);
210 
218  void set_sort_by_key_then_relevance(KeyMaker* sorter,
219  bool reverse) XAPIAN_NONNULL();
220 
247  void set_sort_by_relevance_then_value(valueno sort_key, bool reverse);
248 
269  void set_sort_by_relevance_then_key(KeyMaker* sorter,
270  bool reverse) XAPIAN_NONNULL();
271 
302  void set_collapse_key(valueno collapse_key, doccount collapse_max = 1);
303 
312  void set_cutoff(int percent_threshold, double weight_threshold = 0);
313 
336  void add_matchspy(MatchSpy* spy) XAPIAN_NONNULL();
337 
339  void clear_matchspies();
340 
358  void set_time_limit(double time_limit);
359 
383  MSet get_mset(doccount first,
384  doccount maxitems,
385  doccount checkatleast = 0,
386  const RSet* rset = NULL,
387  const MatchDecider* mdecider = NULL) const;
388 
405  doccount maxitems,
406  const RSet* rset,
407  const MatchDecider* mdecider = NULL) const {
408  return get_mset(first, maxitems, 0, rset, mdecider);
409  }
410 
421  TermIterator get_matching_terms_begin(docid did) const;
422 
431  return get_matching_terms_begin(*it);
432  }
433 
436  return TermIterator();
437  }
438 
441  return TermIterator();
442  }
443 
460  void set_expansion_scheme(std::string_view eweightname,
461  double expand_k = 1.0) const;
462 
469  static const int INCLUDE_QUERY_TERMS = 1;
470 
479  static const int USE_EXACT_TERMFREQ = 2;
480 
501  ESet get_eset(termcount maxitems,
502  const RSet& rset,
503  int flags = 0,
504  const ExpandDecider* edecider = NULL,
505  double min_weight = 0.0) const;
506 
522  const RSet& rset,
523  const ExpandDecider* edecider) const {
524  return get_eset(maxitems, rset, 0, edecider);
525  }
526 
528  std::string get_description() const;
529 };
530 
531 }
532 
533 #endif // XAPIAN_INCLUDED_ENQUIRE_H
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:62
Compiler attribute macros.
#define XAPIAN_NONNULL(LIST)
Annotate function parameters which should be non-NULL pointers.
Definition: attributes.h:84
An indexed database of documents.
Definition: database.h:75
Class representing a list of search results.
Definition: eset.h:42
Querying session.
Definition: enquire.h:57
TermIterator get_matching_terms_begin(const MSetIterator &it) const
Iterate query terms matching a document.
Definition: enquire.h:430
Enquire(const Enquire &o)
Copying is allowed.
Enquire(Enquire &&o)
Move constructor.
ESet get_eset(termcount maxitems, const RSet &rset, const ExpandDecider *edecider) const
Perform query expansion.
Definition: enquire.h:521
Enquire & operator=(const Enquire &o)
Copying is allowed.
TermIterator get_matching_terms_end(const MSetIterator &) const noexcept
End iterator corresponding to get_matching_terms_begin().
Definition: enquire.h:440
Enquire & operator=(Enquire &&o)
Move assignment operator.
MSet get_mset(doccount first, doccount maxitems, const RSet *rset, const MatchDecider *mdecider=NULL) const
Run the query.
Definition: enquire.h:404
TermIterator get_matching_terms_end(docid) const noexcept
End iterator corresponding to get_matching_terms_begin().
Definition: enquire.h:435
Virtual base class for expand decider functor.
Definition: expanddecider.h:38
Virtual base class for key making functors.
Definition: keymaker.h:44
Iterator over a Xapian::MSet.
Definition: mset.h:535
Class representing a list of search results.
Definition: mset.h:46
Abstract base class for match deciders.
Definition: matchdecider.h:37
Abstract base class for match spies.
Definition: matchspy.h:50
Class representing a query.
Definition: query.h:45
Class representing a set of documents judged as relevant.
Definition: rset.h:39
Class for iterating over a list of terms.
Definition: termiterator.h:41
Abstract base class for weighting schemes.
Definition: weight.h:38
Class representing a list of query expansion terms.
Class representing a list of search results.
The Xapian namespace contains public interfaces for the Xapian library.
Definition: compactor.cc:82
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
Definition: types.h:64
unsigned valueno
The number for a value slot in a document.
Definition: types.h:90
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
Definition: types.h:37
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
Definition: types.h:51
Class for iterating over a list of terms.
typedefs for Xapian
Define XAPIAN_VISIBILITY_* macros.
#define XAPIAN_VISIBILITY_DEFAULT
Definition: visibility.h:28