Xapian: API Documentation: Xapian::MultiValueKeyMaker Class Reference

xapian-core 2.0.0

Public Member Functions | List of all members
Xapian::MultiValueKeyMaker Class Reference

KeyMaker subclass which combines several values. More...

`#include <keymaker.h>`

Inheritance diagram for Xapian::MultiValueKeyMaker:
[legend]

## Public Member Functions
template<class Iterator>
| MultiValueKeyMaker (Iterator begin, Iterator end)
| Construct a MultiValueKeyMaker from a pair of iterators.
virtual std::string | operator() (const Xapian::Document &doc) const
| Build a key string for a Document.
void | add_value (Xapian::valueno slot, bool reverse=false, std::string_view defvalue={})
| Add a value slot to the list to build a key from.
std::string | name () const
| Return the name of this KeyMaker.
std::string | serialise () const
| Return this object's parameters serialised as a single string.
KeyMaker * | unserialise (const std::string &serialised, const Registry &context) const
| Unserialise parameters.
Public Member Functions inherited from Xapian::KeyMaker
| KeyMaker ()
| Default constructor.
virtual | ~KeyMaker ()
| Virtual destructor, because we have virtual methods.
KeyMaker * | release ()
| Start reference counting this object.
const KeyMaker * | release () const
| Start reference counting this object.

## Detailed Description

KeyMaker subclass which combines several values.

When the result is used for sorting, results are ordered by the first value. In the event of a tie, the second is used. If this is the same for both, the third is used, and so on. If reverse is true for a value, then the sort order for that value is reversed.

When used for collapsing, the documents will only be considered equal if all the values specified match. If none of the specified values are set then the generated key will be empty, so such documents won't be collapsed (which is consistent with the behaviour in the "collapse on a value" case). If you'd prefer that documents with none of the keys set are collapsed together, then you can set reverse for at least one of the values. Other than this, it isn't useful to set reverse for collapsing.

## Constructor & Destructor Documentation

## ◆ MultiValueKeyMaker()

template<class Iterator>

Xapian::MultiValueKeyMaker::MultiValueKeyMaker | ( | Iterator | begin,
|  | Iterator | end )
| inline

Construct a MultiValueKeyMaker from a pair of iterators.

The iterators must be a begin/end pair returning Xapian::valueno (or a compatible type) when dereferenced.

References add_value().

## Member Function Documentation

## ◆ add_value()

void Xapian::MultiValueKeyMaker::add_value | ( | Xapian::valueno | slot,
|  | bool | reverse = false,
|  | std::string_view | defvalue = {} )
| inline

Add a value slot to the list to build a key from.

Parameters

  slot | The value slot to add
  reverse | Adjust values from this slot to reverse their sort order (default: false)
  defvalue | Value to use for documents which don't have a value set in this slot (default: empty). This can be used to make such documents sort after all others by passing `get_value_upper_bound(slot) + "x"` this is guaranteed to be greater than any value in this slot.

Referenced by MultiValueKeyMaker().

## ◆ name()

std::string Xapian::MultiValueKeyMaker::name | ( |  | ) | const
| virtual

Return the name of this KeyMaker.

This name is used by the remote backend. It is passed with the serialised parameters to the remote server so that it knows which class to create.

Return the full namespace-qualified name of your class here - if your class is called MyApp::FooKeyMaker, return "MyApp::FooKeyMaker" from this method.

If you don't want to support the remote backend in your KeyMaker, you can use the default implementation which simply throws Xapian::UnimplementedError.

Reimplemented from Xapian::KeyMaker.

## ◆ operator()()

virtual std::string Xapian::MultiValueKeyMaker::operator() | ( | const Xapian::Document & | doc | ) | const
| virtual

Build a key string for a Document.

These keys can be used for sorting or collapsing matching documents.

Parameters

  doc | Document object to build a key for.

Implements Xapian::KeyMaker.

## ◆ serialise()

std::string Xapian::MultiValueKeyMaker::serialise | ( |  | ) | const
| virtual

Return this object's parameters serialised as a single string.

If there are no parameters, just return an empty string.

If you don't want to support the remote backend in your KeyMaker, you can use the default implementation which simply throws Xapian::UnimplementedError.

Reimplemented from Xapian::KeyMaker.

## ◆ unserialise()

KeyMaker * Xapian::MultiValueKeyMaker::unserialise | ( | const std::string & | serialised,
|  | const Registry & | context ) const
| virtual

Unserialise parameters.

This method unserialises parameters serialised by the serialise() method and allocates and returns a new object initialised with them.

If you don't want to support the remote backend in your KeyMaker, you can use the default implementation which simply throws Xapian::UnimplementedError.

Note that the returned object will be deallocated by Xapian after use with "delete". If you want to handle the deletion in a special way (for example when wrapping the Xapian API for use from another language) then you can define a static `operator delete` method in your subclass as shown here: https://trac.xapian.org/ticket/554#comment:1

Parameters

  serialised | A string containing the serialised results.
  context | Registry object to use for unserialisation to permit KeyMaker subclasses with sub-KeyMaker objects to be implemented.

Reimplemented from Xapian::KeyMaker.

The documentation for this class was generated from the following file:

- xapian/keymaker.h