Make setting an ErrorHandler a no-op
[xapian.git] / xapian-core / include / xapian / enquire.h
blob09db354b2875b373559d8ceef8b409fb0a119810
1 /** @file enquire.h
2 * @brief API for running queries
3 */
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
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.
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.
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
26 #ifndef XAPIAN_INCLUDED_ENQUIRE_H
27 #define XAPIAN_INCLUDED_ENQUIRE_H
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
33 #include "xapian/deprecated.h"
34 #include <string>
36 #include <xapian/attributes.h>
37 #include <xapian/intrusive_ptr.h>
38 #include <xapian/mset.h>
39 #include <xapian/stem.h>
40 #include <xapian/types.h>
41 #include <xapian/termiterator.h>
42 #include <xapian/visibility.h>
44 namespace Xapian {
46 class Database;
47 class Document;
48 class ErrorHandler;
49 class ExpandDecider;
50 class KeyMaker;
51 class MatchSpy;
52 class Query;
53 class Weight;
55 class ESetIterator;
57 /** Class representing an ordered set of expand terms (an ESet).
58 * This set represents the results of an expand operation, which is
59 * performed by Xapian::Enquire::get_eset().
61 class XAPIAN_VISIBILITY_DEFAULT ESet {
62 public:
63 class Internal;
64 /// @private @internal Reference counted internals.
65 Xapian::Internal::intrusive_ptr<Internal> internal;
67 /// Construct an empty ESet
68 ESet();
70 /// Destructor.
71 ~ESet();
73 /// Copying is allowed (and is cheap).
74 ESet(const ESet & other);
76 /// Assignment is allowed (and is cheap).
77 void operator=(const ESet &other);
79 /** A lower bound on the number of terms which are in the full
80 * set of results of the expand. This will be greater than or
81 * equal to size()
83 Xapian::termcount get_ebound() const;
85 /** The number of terms in this E-Set */
86 Xapian::termcount size() const;
88 /** Required to allow use as an STL container. */
89 Xapian::termcount max_size() const { return size(); }
91 /** Test if this E-Set is empty */
92 bool empty() const;
94 /** Swap the E-Set we point to with another */
95 void swap(ESet & other);
97 /** Iterator for the terms in this E-Set */
98 ESetIterator begin() const;
100 /** End iterator corresponding to begin() */
101 ESetIterator end() const;
103 /** Iterator pointing to the last element of this E-Set */
104 ESetIterator back() const;
106 /** This returns the term at position i in this E-Set.
108 * @param i The index into the ESet.
110 ESetIterator operator[](Xapian::termcount i) const;
112 /// Return a string describing this object.
113 std::string get_description() const;
116 /** Iterate through terms in the ESet */
117 class XAPIAN_VISIBILITY_DEFAULT ESetIterator {
118 private:
119 friend class ESet;
120 friend bool operator==(const ESetIterator &a, const ESetIterator &b) XAPIAN_NOEXCEPT;
121 friend bool operator!=(const ESetIterator &a, const ESetIterator &b) XAPIAN_NOEXCEPT;
122 friend void iterator_rewind(ESetIterator & it);
123 friend bool iterator_valid(const ESetIterator & it);
125 ESetIterator(Xapian::termcount index_, const ESet & eset_)
126 : index(index_), eset(eset_) { }
128 Xapian::termcount index;
129 ESet eset;
131 public:
132 /** Create an uninitialised iterator; this cannot be used, but is
133 * convenient syntactically.
135 XAPIAN_NOTHROW(ESetIterator())
136 : index(0), eset() { }
138 /// Copying is allowed (and is cheap).
139 ESetIterator(const ESetIterator &other) {
140 index = other.index;
141 eset = other.eset;
144 /// Assignment is allowed (and is cheap).
145 void operator=(const ESetIterator &other) {
146 index = other.index;
147 eset = other.eset;
150 /// Advance the iterator.
151 ESetIterator & XAPIAN_NOTHROW(operator++()) {
152 ++index;
153 return *this;
156 /// Advance the iterator (postfix variant).
157 ESetIterator operator++(int) {
158 ESetIterator tmp = *this;
159 ++index;
160 return tmp;
163 /// Decrement the iterator.
164 ESetIterator & XAPIAN_NOTHROW(operator--()) {
165 --index;
166 return *this;
169 /// Decrement the iterator (postfix variant).
170 ESetIterator operator--(int) {
171 ESetIterator tmp = *this;
172 --index;
173 return tmp;
176 /// Get the term for the current position
177 const std::string & operator *() const;
179 /// Get the weight of the term at the current position
180 double get_weight() const;
182 /// Return a string describing this object.
183 std::string get_description() const;
185 /// Allow use as an STL iterator
186 //@{
187 typedef std::bidirectional_iterator_tag iterator_category; // FIXME: go for randomaccess_iterator!
188 typedef std::string value_type;
189 typedef Xapian::termcount_diff difference_type;
190 typedef std::string * pointer;
191 typedef std::string & reference;
192 //@}
195 bool
196 XAPIAN_NOTHROW(operator==(const ESetIterator &a, const ESetIterator &b));
198 /// Equality test for ESetIterator objects.
199 inline bool
200 operator==(const ESetIterator &a, const ESetIterator &b) XAPIAN_NOEXCEPT
202 return (a.index == b.index);
205 bool
206 XAPIAN_NOTHROW(operator!=(const ESetIterator &a, const ESetIterator &b));
208 /// Inequality test for ESetIterator objects.
209 inline bool
210 operator!=(const ESetIterator &a, const ESetIterator &b) XAPIAN_NOEXCEPT
212 return (a.index != b.index);
215 /** A relevance set (R-Set).
216 * This is the set of documents which are marked as relevant, for use
217 * in modifying the term weights, and in performing query expansion.
219 class XAPIAN_VISIBILITY_DEFAULT RSet {
220 public:
221 /// Class holding details of RSet
222 class Internal;
224 /// @private @internal Reference counted internals.
225 Xapian::Internal::intrusive_ptr<Internal> internal;
227 /// Copy constructor
228 RSet(const RSet &rset);
230 /// Assignment operator
231 void operator=(const RSet &rset);
233 /// Default constructor
234 RSet();
236 /// Destructor
237 ~RSet();
239 /** The number of documents in this R-Set */
240 Xapian::doccount size() const;
242 /** Test if this R-Set is empty */
243 bool empty() const;
245 /// Add a document to the relevance set.
246 void add_document(Xapian::docid did);
248 /// Add a document to the relevance set.
249 void add_document(const Xapian::MSetIterator & i) { add_document(*i); }
251 /// Remove a document from the relevance set.
252 void remove_document(Xapian::docid did);
254 /// Remove a document from the relevance set.
255 void remove_document(const Xapian::MSetIterator & i) { remove_document(*i); }
257 /// Test if a given document in the relevance set.
258 bool contains(Xapian::docid did) const;
260 /// Test if a given document in the relevance set.
261 bool contains(const Xapian::MSetIterator & i) const { return contains(*i); }
263 /// Return a string describing this object.
264 std::string get_description() const;
267 /** Base class for matcher decision functor.
269 class XAPIAN_VISIBILITY_DEFAULT MatchDecider {
270 /// Don't allow assignment.
271 void operator=(const MatchDecider &);
273 /// Don't allow copying.
274 MatchDecider(const MatchDecider &);
276 public:
277 /// Default constructor
278 MatchDecider() { }
280 /** Decide whether we want this document to be in the MSet.
282 * @param doc The document to test.
284 * @return true if the document is acceptable, or false if the document
285 * should be excluded from the MSet.
287 virtual bool operator()(const Xapian::Document &doc) const = 0;
289 /// Destructor.
290 virtual ~MatchDecider();
293 /** This class provides an interface to the information retrieval
294 * system for the purpose of searching.
296 * Databases are usually opened lazily, so exceptions may not be
297 * thrown where you would expect them to be. You should catch
298 * Xapian::Error exceptions when calling any method in Xapian::Enquire.
300 * @exception Xapian::InvalidArgumentError will be thrown if an invalid
301 * argument is supplied, for example, an unknown database type.
303 class XAPIAN_VISIBILITY_DEFAULT Enquire {
304 public:
305 /// Copying is allowed (and is cheap).
306 Enquire(const Enquire & other);
308 /// Assignment is allowed (and is cheap).
309 void operator=(const Enquire & other);
311 class Internal;
312 /// @private @internal Reference counted internals.
313 Xapian::Internal::intrusive_ptr<Internal> internal;
315 /** Create a Xapian::Enquire object.
317 * This specification cannot be changed once the Xapian::Enquire is
318 * opened: you must create a new Xapian::Enquire object to access a
319 * different database, or set of databases.
321 * The database supplied must have been initialised (ie, must not be
322 * the result of calling the Database::Database() constructor). If
323 * you need to handle a situation where you have no index gracefully,
324 * a database created with InMemory::open() can be passed here,
325 * which represents a completely empty database.
327 * @param database Specification of the database or databases to
328 * use.
329 * @param errorhandler_ This parameter is deprecated (since Xapian
330 * 1.3.1), and as of 1.3.5 it's ignored completely.
332 * @exception Xapian::InvalidArgumentError will be thrown if an
333 * empty Database object is supplied.
335 explicit Enquire(const Database &database);
336 XAPIAN_DEPRECATED_EX(Enquire(const Database &database, ErrorHandler * errorhandler_));
338 /** Close the Xapian::Enquire object.
340 ~Enquire();
342 /** Set the query to run.
344 * @param query the new query to run.
345 * @param qlen the query length to use in weight calculations -
346 * by default the sum of the wqf of all terms is used.
348 void set_query(const Xapian::Query & query, Xapian::termcount qlen = 0);
350 /** Get the current query.
352 * If called before set_query(), this will return a default
353 * initialised Query object.
355 const Xapian::Query & get_query() const;
357 /** Add a matchspy.
359 * This matchspy will be called with some of the documents which match
360 * the query, during the match process. Exactly which of the matching
361 * documents are passed to it depends on exactly when certain
362 * optimisations occur during the match process, but it can be
363 * controlled to some extent by setting the @a checkatleast parameter
364 * to @a get_mset().
366 * In particular, if there are enough matching documents, at least the
367 * number specified by @a checkatleast will be passed to the matchspy.
368 * This means that you can force the matchspy to be shown all matching
369 * documents by setting @a checkatleast to the number of documents in
370 * the database.
372 * @param spy The MatchSpy subclass to add. The caller must
373 * ensure that this remains valid while the Enquire
374 * object remains active, or until @a
375 * clear_matchspies() is called.
377 void add_matchspy(MatchSpy * spy);
379 /** Remove all the matchspies.
381 void clear_matchspies();
383 /** Set the weighting scheme to use for queries.
385 * @param weight_ the new weighting scheme. If no weighting scheme
386 * is specified, the default is BM25 with the
387 * default parameters.
389 void set_weighting_scheme(const Weight &weight_);
391 /** Set the weighting scheme to use for expansion.
393 * If you don't call this method, the default is as if you'd used:
395 * get_expansion_scheme("trad");
397 * @param eweightname_ A string in lowercase specifying the name of
398 * the scheme to be used. The following schemes
399 * are currently available:
400 * "bo1" : The Bo1 scheme for query expansion.
401 * "trad" : The TradWeight scheme for query expansion.
402 * @param expand_k_ The parameter required for TradWeight query expansion.
403 * A default value of 1.0 is used if none is specified.
405 void set_expansion_scheme(const std::string &eweightname_,
406 double expand_k_ = 1.0) const;
408 /** Set the collapse key to use for queries.
410 * @param collapse_key value number to collapse on - at most one MSet
411 * entry with each particular value will be returned
412 * (default is Xapian::BAD_VALUENO which means no collapsing).
414 * @param collapse_max Max number of items with the same key to leave
415 * after collapsing (default 1).
417 * The MSet returned by get_mset() will have only the "best"
418 * (at most) @a collapse_max entries with each particular
419 * value of @a collapse_key ("best" being highest ranked - i.e.
420 * highest weight or highest sorting key).
422 * An example use might be to create a value for each document
423 * containing an MD5 hash of the document contents. Then
424 * duplicate documents from different sources can be eliminated at
425 * search time by collapsing with @a collapse_max = 1 (it's better
426 * to eliminate duplicates at index time, but this may not be
427 * always be possible - for example the search may be over more
428 * than one Xapian database).
430 * Another use is to group matches in a particular category (e.g.
431 * you might collapse a mailing list search on the Subject: so
432 * that there's only one result per discussion thread). In this
433 * case you can use get_collapse_count() to give the user some
434 * idea how many other results there are. And if you index the
435 * Subject: as a boolean term as well as putting it in a value,
436 * you can offer a link to a non-collapsed search restricted to
437 * that thread using a boolean filter.
439 void set_collapse_key(Xapian::valueno collapse_key,
440 Xapian::doccount collapse_max = 1);
442 typedef enum {
443 ASCENDING = 1,
444 DESCENDING = 0,
445 DONT_CARE = 2
446 } docid_order;
448 /** Set the direction in which documents are ordered by document id
449 * in the returned MSet.
451 * This order only has an effect on documents which would otherwise
452 * have equal rank. For a weighted probabilistic match with no sort
453 * value, this means documents with equal weight. For a boolean match,
454 * with no sort value, this means all documents. And if a sort value
455 * is used, this means documents with equal sort value (and also equal
456 * weight if ordering on relevance after the sort).
458 * @param order This can be:
459 * - Xapian::Enquire::ASCENDING
460 * docids sort in ascending order (default)
461 * - Xapian::Enquire::DESCENDING
462 * docids sort in descending order
463 * - Xapian::Enquire::DONT_CARE
464 * docids sort in whatever order is most efficient for the backend
466 * Note: If you add documents in strict date order, then a boolean
467 * search - i.e. set_weighting_scheme(Xapian::BoolWeight()) - with
468 * set_docid_order(Xapian::Enquire::DESCENDING) is an efficient
469 * way to perform "sort by date, newest first", and with
470 * set_docid_order(Xapian::Enquire::ASCENDING) a very efficient way
471 * to perform "sort by date, oldest first".
473 void set_docid_order(docid_order order);
475 /** Set the percentage and/or weight cutoffs.
477 * @param percent_cutoff Minimum percentage score for returned
478 * documents. If a document has a lower percentage score than this,
479 * it will not appear in the MSet. If your intention is to return
480 * only matches which contain all the terms in the query, then
481 * it's more efficient to use Xapian::Query::OP_AND instead of
482 * Xapian::Query::OP_OR in the query than to use set_cutoff(100).
483 * (default 0 => no percentage cut-off).
484 * @param weight_cutoff Minimum weight for a document to be returned.
485 * If a document has a lower score that this, it will not appear
486 * in the MSet. It is usually only possible to choose an
487 * appropriate weight for cutoff based on the results of a
488 * previous run of the same query; this is thus mainly useful for
489 * alerting operations. The other potential use is with a user
490 * specified weighting scheme.
491 * (default 0 => no weight cut-off).
493 void set_cutoff(int percent_cutoff, double weight_cutoff = 0);
495 /** Set the sorting to be by relevance only.
497 * This is the default.
499 void set_sort_by_relevance();
501 /** Set the sorting to be by value only.
503 * Note that sorting by values uses a string comparison, so to use
504 * this to sort by a numeric value you'll need to store the numeric
505 * values in a manner which sorts appropriately. For example, you
506 * could use Xapian::sortable_serialise() (which works for floating
507 * point numbers as well as integers), or store numbers padded with
508 * leading zeros or spaces, or with the number of digits prepended.
510 * @param sort_key value number to sort on.
512 * @param reverse If true, reverses the sort order.
514 void set_sort_by_value(Xapian::valueno sort_key, bool reverse);
516 /** Set the sorting to be by key generated from values only.
518 * @param sorter The functor to use for generating keys.
520 * @param reverse If true, reverses the sort order.
522 void set_sort_by_key(Xapian::KeyMaker * sorter, bool reverse);
524 /** Set the sorting to be by value, then by relevance for documents
525 * with the same value.
527 * Note that sorting by values uses a string comparison, so to use
528 * this to sort by a numeric value you'll need to store the numeric
529 * values in a manner which sorts appropriately. For example, you
530 * could use Xapian::sortable_serialise() (which works for floating
531 * point numbers as well as integers), or store numbers padded with
532 * leading zeros or spaces, or with the number of digits prepended.
534 * @param sort_key value number to sort on.
536 * @param reverse If true, reverses the sort order.
538 void set_sort_by_value_then_relevance(Xapian::valueno sort_key,
539 bool reverse);
541 /** Set the sorting to be by keys generated from values, then by
542 * relevance for documents with identical keys.
544 * @param sorter The functor to use for generating keys.
546 * @param reverse If true, reverses the sort order.
548 void set_sort_by_key_then_relevance(Xapian::KeyMaker * sorter,
549 bool reverse);
551 /** Set the sorting to be by relevance then value.
553 * Note that sorting by values uses a string comparison, so to use
554 * this to sort by a numeric value you'll need to store the numeric
555 * values in a manner which sorts appropriately. For example, you
556 * could use Xapian::sortable_serialise() (which works for floating
557 * point numbers as well as integers), or store numbers padded with
558 * leading zeros or spaces, or with the number of digits prepended.
560 * Note that with the default BM25 weighting scheme parameters,
561 * non-identical documents will rarely have the same weight, so
562 * this setting will give very similar results to
563 * set_sort_by_relevance(). It becomes more useful with particular
564 * BM25 parameter settings (e.g. BM25Weight(1,0,1,0,0)) or custom
565 * weighting schemes.
567 * @param sort_key value number to sort on.
569 * @param reverse If true, reverses the sort order of sort_key.
570 * Beware that in 1.2.16 and earlier, the sense
571 * of this parameter was incorrectly inverted
572 * and inconsistent with the other set_sort_by_...
573 * methods. This was fixed in 1.2.17, so make that
574 * version a minimum requirement if this detail
575 * matters to your application.
577 void set_sort_by_relevance_then_value(Xapian::valueno sort_key,
578 bool reverse);
580 /** Set the sorting to be by relevance, then by keys generated from
581 * values.
583 * Note that with the default BM25 weighting scheme parameters,
584 * non-identical documents will rarely have the same weight, so
585 * this setting will give very similar results to
586 * set_sort_by_relevance(). It becomes more useful with particular
587 * BM25 parameter settings (e.g. BM25Weight(1,0,1,0,0)) or custom
588 * weighting schemes.
590 * @param sorter The functor to use for generating keys.
592 * @param reverse If true, reverses the sort order of the generated
593 * keys. Beware that in 1.2.16 and earlier, the sense
594 * of this parameter was incorrectly inverted
595 * and inconsistent with the other set_sort_by_...
596 * methods. This was fixed in 1.2.17, so make that
597 * version a minimum requirement if this detail
598 * matters to your application.
600 void set_sort_by_relevance_then_key(Xapian::KeyMaker * sorter,
601 bool reverse);
603 /** Set a time limit for the match.
605 * Matches with check_at_least set high can take a long time in some
606 * cases. You can set a time limit on this, after which check_at_least
607 * will be turned off.
609 * @param time_limit time in seconds after which to disable
610 * check_at_least (default: 0.0 which means no
611 * time limit)
613 * Limitations:
615 * This feature is currently supported on platforms which support POSIX
616 * interval timers. Interaction with the remote backend when using
617 * multiple databases may have bugs. There's not currently a way to
618 * force the match to end after a certain time.
620 void set_time_limit(double time_limit);
622 /** Get (a portion of) the match set for the current query.
624 * @param first the first item in the result set to return.
625 * A value of zero corresponds to the first item
626 * returned being that with the highest score.
627 * A value of 10 corresponds to the first 10 items
628 * being ignored, and the returned items starting
629 * at the eleventh.
630 * @param maxitems the maximum number of items to return. If you
631 * want all matches, then you can pass the result
632 * of calling get_doccount() on the Database object
633 * (though if you are doing this so you can filter
634 * results, you are likely to get much better
635 * performance by using Xapian's match-time filtering
636 * features instead). You can pass 0 for maxitems
637 * which will give you an empty MSet with valid
638 * statistics (such as get_matches_estimated())
639 * calculated without looking at any postings, which
640 * is very quick, but means the estimates may be
641 * more approximate and the bounds may be much
642 * looser.
643 * @param checkatleast the minimum number of items to check. Because
644 * the matcher optimises, it won't consider every
645 * document which might match, so the total number
646 * of matches is estimated. Setting checkatleast
647 * forces it to consider at least this many matches
648 * and so allows for reliable paging links.
649 * @param omrset the relevance set to use when performing the query.
650 * @param mdecider a decision functor to use to decide whether a
651 * given document should be put in the MSet.
653 * @return A Xapian::MSet object containing the results of the
654 * query.
656 * @exception Xapian::InvalidArgumentError See class documentation.
658 * @{
660 MSet get_mset(Xapian::doccount first, Xapian::doccount maxitems,
661 Xapian::doccount checkatleast = 0,
662 const RSet * omrset = 0,
663 const MatchDecider * mdecider = 0) const;
664 MSet get_mset(Xapian::doccount first, Xapian::doccount maxitems,
665 const RSet * omrset,
666 const MatchDecider * mdecider = 0) const {
667 return get_mset(first, maxitems, 0, omrset, mdecider);
669 /** @} */
671 static const int INCLUDE_QUERY_TERMS = 1;
672 static const int USE_EXACT_TERMFREQ = 2;
674 /** Get the expand set for the given rset.
676 * @param maxitems the maximum number of items to return.
677 * @param omrset the relevance set to use when performing
678 * the expand operation.
679 * @param flags zero or more of these values |-ed together:
680 * - Xapian::Enquire::INCLUDE_QUERY_TERMS query
681 * terms may be returned from expand
682 * - Xapian::Enquire::USE_EXACT_TERMFREQ for multi
683 * dbs, calculate the exact termfreq; otherwise an
684 * approximation is used which can greatly improve
685 * efficiency, but still returns good results.
686 * @param edecider a decision functor to use to decide whether a
687 * given term should be put in the ESet
688 * @param min_wt the minimum weight for included terms
690 * @return An ESet object containing the results of the
691 * expand.
693 * @exception Xapian::InvalidArgumentError See class documentation.
695 ESet get_eset(Xapian::termcount maxitems,
696 const RSet & omrset,
697 int flags = 0,
698 const Xapian::ExpandDecider * edecider = 0,
699 double min_wt = 0.0) const;
701 /** Get the expand set for the given rset.
703 * @param maxitems the maximum number of items to return.
704 * @param omrset the relevance set to use when performing
705 * the expand operation.
706 * @param edecider a decision functor to use to decide whether a
707 * given term should be put in the ESet
709 * @return An ESet object containing the results of the
710 * expand.
712 * @exception Xapian::InvalidArgumentError See class documentation.
714 inline ESet get_eset(Xapian::termcount maxitems, const RSet & omrset,
715 const Xapian::ExpandDecider * edecider) const {
716 return get_eset(maxitems, omrset, 0, edecider);
719 /** Get the expand set for the given rset.
721 * @param maxitems the maximum number of items to return.
722 * @param rset the relevance set to use when performing
723 * the expand operation.
724 * @param flags zero or more of these values |-ed together:
725 * - Xapian::Enquire::INCLUDE_QUERY_TERMS query
726 * terms may be returned from expand
727 * - Xapian::Enquire::USE_EXACT_TERMFREQ for multi
728 * dbs, calculate the exact termfreq; otherwise an
729 * approximation is used which can greatly improve
730 * efficiency, but still returns good results.
731 * @param k the parameter k in the query expansion algorithm
732 * (default is 1.0)
733 * @param edecider a decision functor to use to decide whether a
734 * given term should be put in the ESet
736 * @param min_wt the minimum weight for included terms
738 * @return An ESet object containing the results of the
739 * expand.
741 * @exception Xapian::InvalidArgumentError See class documentation.
743 XAPIAN_DEPRECATED(ESet get_eset(Xapian::termcount maxitems,
744 const RSet & rset,
745 int flags,
746 double k,
747 const Xapian::ExpandDecider * edecider = NULL,
748 double min_wt = 0.0) const) {
749 set_expansion_scheme("trad", k);
750 return get_eset(maxitems, rset, flags, edecider, min_wt);
753 /** Get terms which match a given document, by document id.
755 * This method returns the terms in the current query which match
756 * the given document.
758 * It is possible for the document to have been removed from the
759 * database between the time it is returned in an MSet, and the
760 * time that this call is made. If possible, you should specify
761 * an MSetIterator instead of a Xapian::docid, since this will enable
762 * database backends with suitable support to prevent this
763 * occurring.
765 * Note that a query does not need to have been run in order to
766 * make this call.
768 * @param did The document id for which to retrieve the matching
769 * terms.
771 * @return An iterator returning the terms which match the
772 * document. The terms will be returned (as far as this
773 * makes any sense) in the same order as the terms
774 * in the query. Terms will not occur more than once,
775 * even if they do in the query.
777 * @exception Xapian::InvalidArgumentError See class documentation.
778 * @exception Xapian::DocNotFoundError The document specified
779 * could not be found in the database.
781 TermIterator get_matching_terms_begin(Xapian::docid did) const;
783 /** End iterator corresponding to get_matching_terms_begin() */
784 TermIterator XAPIAN_NOTHROW(get_matching_terms_end(Xapian::docid /*did*/) const) {
785 return TermIterator();
788 /** Get terms which match a given document, by match set item.
790 * This method returns the terms in the current query which match
791 * the given document.
793 * If the underlying database has suitable support, using this call
794 * (rather than passing a Xapian::docid) will enable the system to
795 * ensure that the correct data is returned, and that the document
796 * has not been deleted or changed since the query was performed.
798 * @param it The iterator for which to retrieve the matching terms.
800 * @return An iterator returning the terms which match the
801 * document. The terms will be returned (as far as this
802 * makes any sense) in the same order as the terms
803 * in the query. Terms will not occur more than once,
804 * even if they do in the query.
806 * @exception Xapian::InvalidArgumentError See class documentation.
807 * @exception Xapian::DocNotFoundError The document specified
808 * could not be found in the database.
810 TermIterator get_matching_terms_begin(const MSetIterator &it) const;
812 /** End iterator corresponding to get_matching_terms_begin() */
813 TermIterator XAPIAN_NOTHROW(get_matching_terms_end(const MSetIterator &/*it*/) const) {
814 return TermIterator();
817 /// Return a string describing this object.
818 std::string get_description() const;
823 #endif /* XAPIAN_INCLUDED_ENQUIRE_H */