Match

A Match represents a single result from a keyvi lookup.

from keyvi.dictionary import Dictionary

d = Dictionary("data.kv")
m = d.get("some_key")
if m:
    print(m.matched_string, m.value)
class keyvi.Match

Result from a keyvi lookup (dictionary, index, completion), including information about the match.

Which fields of Match are filled with values depends on the lookup method.

dumps(self: keyvi._core.Match) → bytes

Serialize the match to a serialized byte string for persistence.

property end

The end position of the match in the input.

static loads(serialized_match: str) → keyvi._core.Match

Deserialize a match from a serialized byte string.

property matched_string

The matched key string.

msgpacked_value_as_string(self: keyvi._core.Match, compression_algorithm: keyvi._core.CompressionAlgorithm = <CompressionAlgorithm.NO_COMPRESSION: 0>) → bytes

Return the msgpack-encoded value, optionally with compression.

raw_value_as_string(self: keyvi._core.Match) → str

Return the raw value as a string.

property score

The score of the match.

property start

The start position of the match in the input.

property value

The value associated with this match.

value_as_string(self: keyvi._core.Match) → str

Return the value as a string.

property weight

The weight of the match (e.g. used with completion dictionaries).