Index

class Index : public keyvi::index::internal::BaseIndexReader<internal::IndexWriterWorker, internal::Segment>

Public Functions

inline void Set(const std::string &key, const std::string &value)

Set key to given value

Parameters:
  • key – the key

  • value – the value

template<typename ContainerType>
inline void MSet(const std::shared_ptr<ContainerType> &key_values)

Set multiple keys and to multiple values

Parameters:

key_values – a set of keys and values, the container must implement an iterator where each entry has uses .first for the key and .second for the value, e.g. std::map

inline void Delete(const std::string &key)

Delete a key

Parameters:

key – the key

inline void Flush(const bool async = false)

Flush the index, persists all pending writes and makes the accessible.

Parameters:

async – if true only trigger a flush, if false(default) wait until flush has been executed.

inline void ForceMerge(const size_t max_segments = 1)

Force merge all segment to the number of segments given (default 1)

Parameters:

max_segments – maximum number of segments the index should have afterwards

inline dictionary::match_t operator[](const std::string &key)

Get a match for the given key

Parameters:

key – the key

inline bool Contains(const std::string &key)

Check if an entry for a given key exists

Parameters:

key – the key

inline dictionary::MatchIterator::MatchIteratorPair GetNear(const std::string &query, const size_t minimum_exact_prefix = 2, const bool greedy = false)

Match a key near: Match as much as possible exact given the minimum prefix length and then return everything below.

If greedy is True it matches everything below the minimum_prefix_length, but in the order of exact first.

Parameters:
  • query – a query to match against

  • minimum_exact_prefix – prefix length to be matched exact

  • greedy – if true matches everything below minimum prefix

inline dictionary::MatchIterator::MatchIteratorPair GetFuzzy(const std::string &query, const int32_t max_edit_distance, const size_t minimum_exact_prefix = 2)

Match approximate given the query and edit distance

Parameters:
  • query – a query to match against

  • max_edit_distance – the max edit distance allowed for a single match

  • minimum_exact_prefix – prefix length to be matched exact