22 #ifndef XAPIAN_INCLUDED_MSET_H
23 #define XAPIAN_INCLUDED_MSET_H
25 #if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD
26 # error Never use <xapian/mset.h> directly; include <xapian.h> instead.
31 #include <string_view>
70 void diversify_(Xapian::doccount k,
129 template<
typename Iterator>
132 auto distance = last - first;
138 distance !=
static_cast<decltype(distance)
>(size()))) {
140 "doesn't match the number of "
144 while (first != last) {
145 set_item_weight(i, *first);
159 void sort_by_relevance();
181 void diversify(Xapian::doccount k,
185 double sigma_sqr = 1e-3) {
191 if (lambda < 0.0 || lambda > 1.0)
194 diversify_(k, r, lambda, (1.0 - lambda) * b * sigma_sqr * 2.0);
222 int convert_to_percent(
double weight)
const;
248 int convert_to_percent(
const MSetIterator & it)
const;
278 double get_termweight(std::string_view
term)
const;
313 double get_max_attained()
const;
315 double get_max_possible()
const;
324 SNIPPET_BACKGROUND_MODEL = 1,
331 SNIPPET_EXHAUSTIVE = 2,
338 SNIPPET_EMPTY_WITHOUT_MATCH = 4,
363 SNIPPET_NGRAMS = 2048,
372 SNIPPET_CJK_NGRAM = SNIPPET_NGRAMS,
387 SNIPPET_WORD_BREAKS = 4096
419 std::string snippet(std::string_view text,
422 unsigned flags = SNIPPET_BACKGROUND_MODEL|SNIPPET_EXHAUSTIVE,
423 std::string_view hi_start =
"<b>",
424 std::string_view hi_end =
"</b>",
425 std::string_view omit =
"...")
const;
467 bool empty()
const {
return size() == 0; }
485 std::string get_description()
const;
539 : mset(mset_), off_from_end(off_from_end_) { }
652 double get_weight()
const;
658 std::string get_collapse_key()
const;
685 std::string get_sort_key()
const;
716 std::string get_description()
const;
723 return a.off_from_end == b.off_from_end;
737 return a.off_from_end > b.off_from_end;
Compiler attribute macros.
Class representing a document.
InvalidArgumentError indicates an invalid parameter value was passed to the API.
Iterator over a Xapian::MSet.
MSetIterator operator-(difference_type n) const
Return the iterator decremented by n positions.
MSetIterator & operator+=(difference_type n)
Move the iterator forwards by n positions.
MSetIterator()
Create an unpositioned MSetIterator.
std::random_access_iterator_tag iterator_category
Xapian::doccount get_rank() const
Return the MSet rank for the current position.
MSetIterator & operator--()
Move the iterator to the previous position.
int get_percent() const
Convert the weight of the current iterator position to a percentage.
Xapian::MSet::size_type off_from_end
MSetIterator & operator-=(difference_type n)
Move the iterator back by n positions.
Xapian::termcount_diff difference_type
MSetIterator operator+(difference_type n) const
Return the iterator incremented by n positions.
double get_weight() const
Get the weight for the current position.
MSetIterator(const Xapian::MSet &mset_, Xapian::doccount off_from_end_)
MSetIterator & operator++()
Advance the iterator to the next position.
MSetIterator operator--(int)
Move the iterator to the previous position (postfix version).
difference_type operator-(const MSetIterator &o) const
Return the number of positions between o and this iterator.
MSetIterator operator++(int)
Advance the iterator to the next position (postfix version).
Class representing a list of search results.
Xapian::Internal::intrusive_ptr_nonnull< Internal > internal
MSet(MSet &&o)
Move constructor.
Xapian::doccount_diff difference_type
Xapian::doccount size() const
Return number of items in this MSet object.
MSet(const MSet &o)
Copying is allowed.
void fetch() const
Prefetch hint the whole MSet.
void replace_weights(Iterator first, Iterator last)
Assigns new weights and updates MSet.
Xapian::doccount max_size() const
void fetch_(Xapian::doccount first, Xapian::doccount last) const
Xapian::doccount size_type
Xapian::MSetIterator value_type
friend class MSetIterator
MSet & operator=(MSet &&o)
Move assignment operator.
int convert_to_percent(double weight) const
Convert a weight to a percentage.
Xapian::MSetIterator iterator
bool empty() const
Return true if this MSet object is empty.
MSet & operator=(const MSet &o)
Copying is allowed.
Xapian::doccount get_firstitem() const
Rank of first item in this MSet.
MSetIterator operator[](Xapian::doccount i) const
Return iterator pointing to the i-th object in this MSet.
MSetIterator back() const
Return iterator pointing to the last object in this MSet.
void swap(MSet &o)
Efficiently swap this MSet object with another.
MSetIterator begin() const
Return iterator pointing to the first item in this MSet.
const value_type const_reference
Xapian::MSetIterator const_iterator
MSetIterator end() const
Return iterator pointing to just after the last item in this MSet.
const value_type * const_pointer
Class representing a stemming algorithm.
Class representing a document.
Hierarchy of classes which Xapian can throw as exceptions.
The Xapian namespace contains public interfaces for the Xapian library.
XAPIAN_DOCID_BASE_TYPE doccount_diff
A signed difference between two counts of documents.
bool operator>(const ESetIterator &a, const ESetIterator &b) noexcept
Inequality test for ESetIterator objects.
XAPIAN_TERMCOUNT_BASE_TYPE termcount_diff
A signed difference between two counts of terms.
bool operator>=(const ESetIterator &a, const ESetIterator &b) noexcept
Inequality test for ESetIterator objects.
bool operator<=(const ESetIterator &a, const ESetIterator &b) noexcept
Inequality test for ESetIterator objects.
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
bool operator==(const ESetIterator &a, const ESetIterator &b) noexcept
Equality test for ESetIterator objects.
bool operator!=(const ESetIterator &a, const ESetIterator &b) noexcept
Inequality test for ESetIterator objects.
ESetIterator operator+(ESetIterator::difference_type n, const ESetIterator &it)
Return ESetIterator it incremented by n positions.
bool operator<(const ESetIterator &a, const ESetIterator &b) noexcept
Inequality test for ESetIterator objects.
const Query operator*(double factor, const Query &q)
Scale a Xapian::Query object using OP_SCALE_WEIGHT.
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
static Xapian::Stem stemmer
Define XAPIAN_VISIBILITY_* macros.
#define XAPIAN_VISIBILITY_DEFAULT
#define XAPIAN_VISIBILITY_INTERNAL