LCOV - code coverage report
Current view: top level - include/xapian - enquire.h (source / functions) Hit Total Coverage
Test: Test Coverage for xapian-core 7822d31adece Lines: 11 11 100.0 %
Date: 2019-05-23 11:15:29 Functions: 9 9 100.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /** @file enquire.h
       2                 :            :  * @brief Querying session
       3                 :            :  */
       4                 :            : /* Copyright (C) 2005,2013,2016,2017 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, write to the Free Software
      19                 :            :  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
      20                 :            :  * USA
      21                 :            :  */
      22                 :            : 
      23                 :            : #ifndef XAPIAN_INCLUDED_ENQUIRE_H
      24                 :            : #define XAPIAN_INCLUDED_ENQUIRE_H
      25                 :            : 
      26                 :            : #if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD
      27                 :            : # error "Never use <xapian/enquire.h> directly; include <xapian.h> instead."
      28                 :            : #endif
      29                 :            : 
      30                 :            : #include <string>
      31                 :            : 
      32                 :            : #include <xapian/attributes.h>
      33                 :            : #include <xapian/eset.h>
      34                 :            : #include <xapian/intrusive_ptr.h>
      35                 :            : #include <xapian/mset.h>
      36                 :            : #include <xapian/types.h>
      37                 :            : #include <xapian/termiterator.h>
      38                 :            : #include <xapian/visibility.h>
      39                 :            : 
      40                 :            : namespace Xapian {
      41                 :            : 
      42                 :            : // Forward declarations of classes referenced below.
      43                 :            : class Database;
      44                 :            : class ExpandDecider;
      45                 :            : class KeyMaker;
      46                 :            : class MatchDecider;
      47                 :            : class MatchSpy;
      48                 :            : class Query;
      49                 :            : class RSet;
      50                 :            : class Weight;
      51                 :            : 
      52                 :            : /** Querying session.
      53                 :            :  *
      54                 :            :  *  An Enquire object represents a querying session - most of the options for
      55                 :            :  *  running a query can be set on it, and the query is run via
      56                 :            :  *  Enquire::get_mset().
      57                 :            :  */
      58                 :          8 : class XAPIAN_VISIBILITY_DEFAULT Enquire {
      59                 :            :   public:
      60                 :            :     /// Class representing the Enquire internals.
      61                 :            :     class Internal;
      62                 :            :     /// @private @internal Reference counted internals.
      63                 :            :     Xapian::Internal::intrusive_ptr_nonnull<Internal> internal;
      64                 :            : 
      65                 :            :     /** Copying is allowed.
      66                 :            :      *
      67                 :            :      *  The internals are reference counted, so copying is cheap.
      68                 :            :      */
      69                 :            :     Enquire(const Enquire& o);
      70                 :            : 
      71                 :            :     /** Copying is allowed.
      72                 :            :      *
      73                 :            :      *  The internals are reference counted, so assignment is cheap.
      74                 :            :      */
      75                 :            :     Enquire& operator=(const Enquire& o);
      76                 :            : 
      77                 :            :     /// Move constructor.
      78                 :            :     Enquire(Enquire&& o);
      79                 :            : 
      80                 :            :     /// Move assignment operator.
      81                 :            :     Enquire& operator=(Enquire&& o);
      82                 :            : 
      83                 :            :     /** Constructor.
      84                 :            :      *
      85                 :            :      *  @param db       The database (or databases) to query.
      86                 :            :      *
      87                 :            :      *  @since 1.5.0 If @a db has no subdatabases, it's handled like any other
      88                 :            :      *  empty database.  In earlier versions, Xapian::InvalidArgumentError was
      89                 :            :      *  thrown in this case.
      90                 :            :      */
      91                 :            :     explicit
      92                 :            :     Enquire(const Database& db);
      93                 :            : 
      94                 :            :     /// Destructor.
      95                 :            :     ~Enquire();
      96                 :            : 
      97                 :            :     /** Set the query.
      98                 :            :      *
      99                 :            :      *  If set_query() is not called before calling get_mset(), the default
     100                 :            :      *  query used will be Xapian::MatchNothing.
     101                 :            :      *
     102                 :            :      *  @param query            The Xapian::Query object
     103                 :            :      *  @param query_length     The query length to use (default:
     104                 :            :      *                          query.get_length())
     105                 :            :      */
     106                 :            :     void set_query(const Query& query, termcount query_length = 0);
     107                 :            : 
     108                 :            :     /** Get the currently set query.
     109                 :            :      *
     110                 :            :      *  If set_query() is not called before calling get_query(), then the
     111                 :            :      *  default query Xapian::MatchNothing will be returned.
     112                 :            :      */
     113                 :            :     const Query& get_query() const;
     114                 :            : 
     115                 :            :     /** Set the weighting scheme to use.
     116                 :            :      *
     117                 :            :      *  The Xapian::Weight object passed is cloned by calling weight.clone(),
     118                 :            :      *  so doesn't need to remain valid after the call.
     119                 :            :      *
     120                 :            :      *  If set_weighting_scheme() is not called before calling get_mset(), the
     121                 :            :      *  default weighting scheme is Xapian::BM25Weight().
     122                 :            :      *
     123                 :            :      *  @param weight   Xapian::Weight object
     124                 :            :      */
     125                 :            :     void set_weighting_scheme(const Weight& weight);
     126                 :            : 
     127                 :            :     /** Ordering of docids.
     128                 :            :      *
     129                 :            :      *  Parameter to Enquire::set_docid_order().
     130                 :            :      */
     131                 :            :     typedef enum {
     132                 :            :         /** docids sort in ascending order (default) */
     133                 :            :         ASCENDING = 1,
     134                 :            :         /** docids sort in descending order. */
     135                 :            :         DESCENDING = 0,
     136                 :            :         /** docids sort in whatever order is most efficient for the backend. */
     137                 :            :         DONT_CARE = 2
     138                 :            :     } docid_order;
     139                 :            : 
     140                 :            :     /** Set sort order for document IDs.
     141                 :            :      *
     142                 :            :      *  This order only has an effect on documents which would otherwise
     143                 :            :      *  have equal rank.  When ordering by relevance without a sort key,
     144                 :            :      *  this means documents with equal weight.  For a boolean match
     145                 :            :      *  with no sort key, this means all documents.  And if a sort key
     146                 :            :      *  is used, this means documents with the same sort key (and also equal
     147                 :            :      *  weight if ordering on relevance before or after the sort key).
     148                 :            :      *
     149                 :            :      * @param order  This can be:
     150                 :            :      * - Xapian::Enquire::ASCENDING
     151                 :            :      *   docids sort in ascending order (default)
     152                 :            :      * - Xapian::Enquire::DESCENDING
     153                 :            :      *   docids sort in descending order
     154                 :            :      * - Xapian::Enquire::DONT_CARE
     155                 :            :      *   docids sort in whatever order is most efficient for the backend
     156                 :            :      *
     157                 :            :      *  Note: If you add documents in strict date order, then a boolean
     158                 :            :      *  search - i.e. set_weighting_scheme(Xapian::BoolWeight()) - with
     159                 :            :      *  set_docid_order(Xapian::Enquire::DESCENDING) is an efficient
     160                 :            :      *  way to perform "sort by date, newest first", and with
     161                 :            :      *  set_docid_order(Xapian::Enquire::ASCENDING) a very efficient way
     162                 :            :      *  to perform "sort by date, oldest first".
     163                 :            :      */
     164                 :            :     void set_docid_order(docid_order order);
     165                 :            : 
     166                 :            :     /** Set the sorting to be by relevance only.
     167                 :            :      *
     168                 :            :      *  This is the default.
     169                 :            :      */
     170                 :            :     void set_sort_by_relevance();
     171                 :            : 
     172                 :            :     /** Set the sorting to be by value only.
     173                 :            :      *
     174                 :            :      *  Note that sorting by values uses a string comparison, so to use
     175                 :            :      *  this to sort by a numeric value you'll need to store the numeric
     176                 :            :      *  values in a manner which sorts appropriately.  For example, you
     177                 :            :      *  could use Xapian::sortable_serialise() (which works for floating
     178                 :            :      *  point numbers as well as integers), or store numbers padded with
     179                 :            :      *  leading zeros or spaces, or with the number of digits prepended.
     180                 :            :      *
     181                 :            :      * @param sort_key  value number to sort on.
     182                 :            :      *
     183                 :            :      * @param reverse   If true, reverses the sort order.
     184                 :            :      */
     185                 :            :     void set_sort_by_value(valueno sort_key, bool reverse);
     186                 :            : 
     187                 :            :     /** Set the sorting to be by key generated from values only.
     188                 :            :      *
     189                 :            :      * @param sorter    The functor to use for generating keys.
     190                 :            :      *
     191                 :            :      * @param reverse   If true, reverses the sort order.
     192                 :            :      */
     193                 :            :     void set_sort_by_key(KeyMaker* sorter,
     194                 :            :                          bool reverse) XAPIAN_NONNULL();
     195                 :            : 
     196                 :            :     /** Set the sorting to be by value, then by relevance for documents
     197                 :            :      *  with the same value.
     198                 :            :      *
     199                 :            :      *  Note that sorting by values uses a string comparison, so to use
     200                 :            :      *  this to sort by a numeric value you'll need to store the numeric
     201                 :            :      *  values in a manner which sorts appropriately.  For example, you
     202                 :            :      *  could use Xapian::sortable_serialise() (which works for floating
     203                 :            :      *  point numbers as well as integers), or store numbers padded with
     204                 :            :      *  leading zeros or spaces, or with the number of digits prepended.
     205                 :            :      *
     206                 :            :      * @param sort_key  value number to sort on.
     207                 :            :      *
     208                 :            :      * @param reverse   If true, reverses the sort order.
     209                 :            :      */
     210                 :            :     void set_sort_by_value_then_relevance(valueno sort_key, bool reverse);
     211                 :            : 
     212                 :            :     /** Set the sorting to be by keys generated from values, then by
     213                 :            :      *  relevance for documents with identical keys.
     214                 :            :      *
     215                 :            :      * @param sorter    The functor to use for generating keys.
     216                 :            :      *
     217                 :            :      * @param reverse   If true, reverses the sort order.
     218                 :            :      */
     219                 :            :     void set_sort_by_key_then_relevance(KeyMaker* sorter,
     220                 :            :                                         bool reverse) XAPIAN_NONNULL();
     221                 :            : 
     222                 :            :     /** Set the sorting to be by relevance then value.
     223                 :            :      *
     224                 :            :      *  Note that sorting by values uses a string comparison, so to use
     225                 :            :      *  this to sort by a numeric value you'll need to store the numeric
     226                 :            :      *  values in a manner which sorts appropriately.  For example, you
     227                 :            :      *  could use Xapian::sortable_serialise() (which works for floating
     228                 :            :      *  point numbers as well as integers), or store numbers padded with
     229                 :            :      *  leading zeros or spaces, or with the number of digits prepended.
     230                 :            :      *
     231                 :            :      *  Note that with the default BM25 weighting scheme parameters,
     232                 :            :      *  non-identical documents will rarely have the same weight, so
     233                 :            :      *  this setting will give very similar results to
     234                 :            :      *  set_sort_by_relevance().  It becomes more useful with particular
     235                 :            :      *  BM25 parameter settings (e.g. BM25Weight(1,0,1,0,0)) or custom
     236                 :            :      *  weighting schemes.
     237                 :            :      *
     238                 :            :      * @param sort_key  value number to sort on.
     239                 :            :      *
     240                 :            :      * @param reverse   If true, reverses the sort order of sort_key.
     241                 :            :      *                  Beware that in 1.2.16 and earlier, the sense
     242                 :            :      *                  of this parameter was incorrectly inverted
     243                 :            :      *                  and inconsistent with the other set_sort_by_...
     244                 :            :      *                  methods.  This was fixed in 1.2.17, so make that
     245                 :            :      *                  version a minimum requirement if this detail
     246                 :            :      *                  matters to your application.
     247                 :            :      */
     248                 :            :     void set_sort_by_relevance_then_value(valueno sort_key, bool reverse);
     249                 :            : 
     250                 :            :     /** Set the sorting to be by relevance, then by keys generated from
     251                 :            :      *  values.
     252                 :            :      *
     253                 :            :      *  Note that with the default BM25 weighting scheme parameters,
     254                 :            :      *  non-identical documents will rarely have the same weight, so
     255                 :            :      *  this setting will give very similar results to
     256                 :            :      *  set_sort_by_relevance().  It becomes more useful with particular
     257                 :            :      *  BM25 parameter settings (e.g. BM25Weight(1,0,1,0,0)) or custom
     258                 :            :      *  weighting schemes.
     259                 :            :      *
     260                 :            :      * @param sorter    The functor to use for generating keys.
     261                 :            :      *
     262                 :            :      * @param reverse   If true, reverses the sort order of the generated
     263                 :            :      *                  keys.  Beware that in 1.2.16 and earlier, the sense
     264                 :            :      *                  of this parameter was incorrectly inverted
     265                 :            :      *                  and inconsistent with the other set_sort_by_...
     266                 :            :      *                  methods.  This was fixed in 1.2.17, so make that
     267                 :            :      *                  version a minimum requirement if this detail
     268                 :            :      *                  matters to your application.
     269                 :            :      */
     270                 :            :     void set_sort_by_relevance_then_key(KeyMaker* sorter,
     271                 :            :                                         bool reverse) XAPIAN_NONNULL();
     272                 :            : 
     273                 :            :     /** Control collapsing of results.
     274                 :            :      *
     275                 :            :      *  The MSet returned by @a get_mset() will have only the "best" (at most)
     276                 :            :      *  @a collapse_max documents with each particular non-empty value in slot
     277                 :            :      *  @a collapse_key ("best" being highest ranked - i.e. highest weight or
     278                 :            :      *  highest sorting key).
     279                 :            :      *
     280                 :            :      *  An example use might be to create a value for each document
     281                 :            :      *  containing an MD5 hash of the document contents.  Then
     282                 :            :      *  duplicate documents from different sources can be eliminated at
     283                 :            :      *  search time by collapsing with @a collapse_max = 1 (it's better
     284                 :            :      *  to eliminate duplicates at index time, but this may not be
     285                 :            :      *  always be possible - for example the search may be over more
     286                 :            :      *  than one Xapian database).
     287                 :            :      *
     288                 :            :      *  Another use is to group matches in a particular category (e.g.
     289                 :            :      *  you might collapse a mailing list search on the Subject: so
     290                 :            :      *  that there's only one result per discussion thread).  In this
     291                 :            :      *  case you can use get_collapse_count() to give the user some
     292                 :            :      *  idea how many other results there are.  And if you index the
     293                 :            :      *  Subject: as a boolean term as well as putting it in a value,
     294                 :            :      *  you can offer a link to a non-collapsed search restricted to
     295                 :            :      *  that thread using a boolean filter.
     296                 :            :      *
     297                 :            :      *  @param collapse_key     value slot to collapse on (default is
     298                 :            :      *                          Xapian::BAD_VALUENO which means no collapsing).
     299                 :            :      *
     300                 :            :      *  @param collapse_max     Maximum number of documents with the same key
     301                 :            :      *                          to allow (default: 1).
     302                 :            :      */
     303                 :            :     void set_collapse_key(valueno collapse_key, doccount collapse_max = 1);
     304                 :            : 
     305                 :            :     /** Set lower bounds on percentage and/or weight.
     306                 :            :      *
     307                 :            :      *  @param percent_threshold        Lower bound on percentage score
     308                 :            :      *  @param weight_threshold         Lower bound on weight (default: 0)
     309                 :            :      *
     310                 :            :      *  No thresholds are applied by default, and if either threshold is set
     311                 :            :      *  to 0, then that threshold is disabled.
     312                 :            :      */
     313                 :            :     void set_cutoff(int percent_threshold, double weight_threshold = 0);
     314                 :            : 
     315                 :            :     /** Add a matchspy.
     316                 :            :      *
     317                 :            :      *  This matchspy will be called with some of the documents which match
     318                 :            :      *  the query, during the match process.  Exactly which of the matching
     319                 :            :      *  documents are passed to it depends on exactly when certain
     320                 :            :      *  optimisations occur during the match process, but it can be
     321                 :            :      *  controlled to some extent by setting the @a checkatleast parameter
     322                 :            :      *  to @a get_mset().
     323                 :            :      *
     324                 :            :      *  In particular, if there are enough matching documents, at least the
     325                 :            :      *  number specified by @a checkatleast will be passed to the matchspy.
     326                 :            :      *  This means that you can force the matchspy to be shown all matching
     327                 :            :      *  documents by setting @a checkatleast to the number of documents in
     328                 :            :      *  the database.
     329                 :            :      *
     330                 :            :      *  @param spy       The MatchSpy subclass to add.  The caller must
     331                 :            :      *                   ensure that this remains valid while the Enquire
     332                 :            :      *                   object remains active, or until @a
     333                 :            :      *                   clear_matchspies() is called, or else disown the
     334                 :            :      *                   MatchSpy object by calling spy->release() before
     335                 :            :      *                   passing it in.
     336                 :            :      */
     337                 :            :     void add_matchspy(MatchSpy* spy) XAPIAN_NONNULL();
     338                 :            : 
     339                 :            :     /** Remove all the matchspies. */
     340                 :            :     void clear_matchspies();
     341                 :            : 
     342                 :            :     /** Set a time limit for the match.
     343                 :            :      *
     344                 :            :      *  Matches with check_at_least set high can take a long time in some
     345                 :            :      *  cases.  You can set a time limit on this, after which check_at_least
     346                 :            :      *  will be turned off.
     347                 :            :      *
     348                 :            :      *  @param time_limit  time in seconds after which to disable
     349                 :            :      *                     check_at_least (default: 0.0 which means no
     350                 :            :      *                     time limit)
     351                 :            :      *
     352                 :            :      *  Limitations:
     353                 :            :      *
     354                 :            :      *  This feature is currently supported on platforms which support POSIX
     355                 :            :      *  interval timers.  Interaction with the remote backend when using
     356                 :            :      *  multiple databases may have bugs.  There's not currently a way to
     357                 :            :      *  force the match to end after a certain time.
     358                 :            :      */
     359                 :            :     void set_time_limit(double time_limit);
     360                 :            : 
     361                 :            :     /** Run the query.
     362                 :            :      *
     363                 :            :      *  Run the query using the settings in this Enquire object and those
     364                 :            :      *  passed as parameters to the method, and return a Xapian::MSet object.
     365                 :            :      *
     366                 :            :      *  @param first            Zero-based index of the first result to return
     367                 :            :      *                          (which supports retrieving pages of results).
     368                 :            :      *  @param maxitems         The maximum number of documents to return.
     369                 :            :      *  @param checkatleast     Check at least this many documents.  By default
     370                 :            :      *                          Xapian will avoiding considering documents
     371                 :            :      *                          which it can prove can't match, which is faster
     372                 :            :      *                          but can result in a loose bounds on and a poor
     373                 :            :      *                          estimate of the total number of matches -
     374                 :            :      *                          setting checkatleast higher allows trading off
     375                 :            :      *                          speed for tighter bounds and a more accurate
     376                 :            :      *                          estimate.  (default: 0)
     377                 :            :      *  @param rset             Documents marked as relevant (default: no
     378                 :            :      *                          documents have been marked as relevant)
     379                 :            :      *  @param mdecider         Xapian::MatchDecider object - this acts as a
     380                 :            :      *                          yes/no filter on documents which match the
     381                 :            :      *                          query.  See also Xapian::PostingSource.
     382                 :            :      *                          (default: no Xapian::MatchDecider)
     383                 :            :      */
     384                 :            :     MSet get_mset(doccount first,
     385                 :            :                   doccount maxitems,
     386                 :            :                   doccount checkatleast = 0,
     387                 :            :                   const RSet* rset = NULL,
     388                 :            :                   const MatchDecider* mdecider = NULL) const;
     389                 :            : 
     390                 :            :     /** Run the query.
     391                 :            :      *
     392                 :            :      *  Run the query using the settings in this Enquire object and those
     393                 :            :      *  passed as parameters to the method, and return a Xapian::MSet object.
     394                 :            :      *
     395                 :            :      *  @param first            Zero-based index of the first result to return
     396                 :            :      *                          (which supports retrieving pages of results).
     397                 :            :      *  @param maxitems         The maximum number of documents to return.
     398                 :            :      *  @param rset             Documents marked as relevant (default: no
     399                 :            :      *                          documents have been marked as relevant)
     400                 :            :      *  @param mdecider         Xapian::MatchDecider object - this acts as a
     401                 :            :      *                          yes/no filter on documents which match the
     402                 :            :      *                          query.  See also Xapian::PostingSource.
     403                 :            :      *                          (default: no Xapian::MatchDecider)
     404                 :            :      */
     405                 :         85 :     MSet get_mset(doccount first,
     406                 :            :                   doccount maxitems,
     407                 :            :                   const RSet* rset,
     408                 :            :                   const MatchDecider* mdecider = NULL) const {
     409                 :         85 :         return get_mset(first, maxitems, 0, rset, mdecider);
     410                 :            :     }
     411                 :            : 
     412                 :            :     /** Iterate query terms matching a document.
     413                 :            :      *
     414                 :            :      *  Takes terms from the query set by @a set_query() and from the document
     415                 :            :      *  with document ID @a did in the database set in the constructor, and
     416                 :            :      *  returns terms which are in both, ordered by ascending query position.
     417                 :            :      *  Terms which occur more than once in the query are only returned once,
     418                 :            :      *  at the lowest term position they occur at.
     419                 :            :      *
     420                 :            :      *  @param did      Document ID in the database set in the constructor
     421                 :            :      */
     422                 :            :     TermIterator get_matching_terms_begin(docid did) const;
     423                 :            : 
     424                 :            :     /** Iterate query terms matching a document.
     425                 :            :      *
     426                 :            :      *  Convenience overloaded form, taking a Xapian::MSetIterator instead
     427                 :            :      *  of a Xapian::docid.
     428                 :            :      *
     429                 :            :      *  @param it       MSetIterator to return matching terms for
     430                 :            :      */
     431                 :         86 :     TermIterator get_matching_terms_begin(const MSetIterator& it) const {
     432                 :         86 :         return get_matching_terms_begin(*it);
     433                 :            :     }
     434                 :            : 
     435                 :            :     /// End iterator corresponding to @a get_matching_terms_begin().
     436                 :          7 :     TermIterator XAPIAN_NOTHROW(get_matching_terms_end(docid) const) {
     437                 :          7 :         return TermIterator();
     438                 :            :     }
     439                 :            : 
     440                 :            :     /// End iterator corresponding to @a get_matching_terms_begin().
     441                 :        254 :     TermIterator XAPIAN_NOTHROW(get_matching_terms_end(const MSetIterator&) const) {
     442                 :        254 :         return TermIterator();
     443                 :            :     }
     444                 :            : 
     445                 :            :     /** Set the weighting scheme to use for expansion.
     446                 :            :      *
     447                 :            :      *  If you don't call this method, the default is as if you'd used:
     448                 :            :      *
     449                 :            :      *  get_expansion_scheme("trad");
     450                 :            :      *
     451                 :            :      *  @param eweightname  A string in lowercase specifying the name of
     452                 :            :      *                      the scheme to be used. The following schemes
     453                 :            :      *                      are currently available:
     454                 :            :      *                       "bo1" : The Bo1 scheme for query expansion.
     455                 :            :      *                       "trad" : The TradWeight scheme for query expansion.
     456                 :            :      *  @param expand_k  The parameter required for TradWeight query expansion.
     457                 :            :      *                   A default value of 1.0 is used if none is specified.
     458                 :            :      */
     459                 :            :     void set_expansion_scheme(const std::string &eweightname,
     460                 :            :                               double expand_k = 1.0) const;
     461                 :            : 
     462                 :            :     /** Flag telling get_eset() to allow query terms in Xapian::ESet.
     463                 :            :      *
     464                 :            :      *  By default, query terms are excluded.  This is appropriate when using
     465                 :            :      *  get_eset() to generate terms for query expansion, but for some other
     466                 :            :      *  uses query terms are also interesting.
     467                 :            :      */
     468                 :            :     static const int INCLUDE_QUERY_TERMS = 1;
     469                 :            : 
     470                 :            :     /** Flag telling get_eset() to always use the exact term frequency.
     471                 :            :      *
     472                 :            :      *  By default, get_eset() approximates the term frequency in some cases
     473                 :            :      *  (currently when we're expanding from more than one database and there
     474                 :            :      *  are sub-databases which don't contain any documents marked as
     475                 :            :      *  relevant).  This is faster and should still return good results, but
     476                 :            :      *  this flag allows the exact term frequency to always be used.
     477                 :            :      */
     478                 :            :     static const int USE_EXACT_TERMFREQ = 2;
     479                 :            : 
     480                 :            :     /** Perform query expansion.
     481                 :            :      *
     482                 :            :      *  Perform query expansion using a Xapian::RSet indicating some documents
     483                 :            :      *  which are relevant (typically based on the user marking results or
     484                 :            :      *  similar).
     485                 :            :      *
     486                 :            :      *  @param maxitems         The maximum number of terms to return.
     487                 :            :      *  @param rset             Documents marked as relevant.
     488                 :            :      *  @param flags            Bitwise-or combination of @a
     489                 :            :      *                          INCLUDE_QUERY_TERMS and @a USE_EXACT_TERMFREQ
     490                 :            :      *                          flags (default: 0).
     491                 :            :      *  @param edecider         Xapian::ExpandDecider object - this acts as a
     492                 :            :      *                          yes/no filter on terms which are being
     493                 :            :      *                          considered.  (default: no
     494                 :            :      *                          Xapian::ExpandDecider)
     495                 :            :      *  @param min_weight       Lower bound on weight of acceptable terms
     496                 :            :      *                          (default: 0.0)
     497                 :            :      *
     498                 :            :      *  @return Xapian::ESet object containing a list of terms with weights.
     499                 :            :      */
     500                 :            :     ESet get_eset(termcount maxitems,
     501                 :            :                   const RSet& rset,
     502                 :            :                   int flags = 0,
     503                 :            :                   const ExpandDecider* edecider = NULL,
     504                 :            :                   double min_weight = 0.0) const;
     505                 :            : 
     506                 :            :     /** Perform query expansion.
     507                 :            :      *
     508                 :            :      *  Perform query expansion using a Xapian::RSet indicating some documents
     509                 :            :      *  which are relevant (typically based on the user marking results or
     510                 :            :      *  similar).
     511                 :            :      *
     512                 :            :      *  @param maxitems         The maximum number of terms to return.
     513                 :            :      *  @param rset             Documents marked as relevant.
     514                 :            :      *  @param edecider         Xapian::ExpandDecider object - this acts as a
     515                 :            :      *                          yes/no filter on terms which are being
     516                 :            :      *                          considered.
     517                 :            :      *
     518                 :            :      *  @return Xapian::ESet object containing a list of terms with weights.
     519                 :            :      */
     520                 :         14 :     inline ESet get_eset(termcount maxitems,
     521                 :            :                          const RSet& rset,
     522                 :            :                          const ExpandDecider* edecider) const {
     523                 :         14 :         return get_eset(maxitems, rset, 0, edecider);
     524                 :            :     }
     525                 :            : 
     526                 :            :     /// Return a string describing this object.
     527                 :            :     std::string get_description() const;
     528                 :            : };
     529                 :            : 
     530                 :            : }
     531                 :            : 
     532                 :            : #endif // XAPIAN_INCLUDED_ENQUIRE_H

Generated by: LCOV version 1.11