lethe.index – Relational data index

This module implements an index for the datastore.

The index is implemented as an SQLite 3 database.

It provides fast access to data about the current state of the site. History is not indexed, each access to it requires direct access to the DVCS repository.

Despite the database terminology, this is not a relational database index: the whole database works as an index to the data in the current revision of the DVCS.

The index format is not documented and changes often. The index_revision site property stored only in the index is used to determine which format is used. Access to an index file of different revision will fail, remove it and regenerate to use it with the current version of Lethe.


refer to the UI for syncing the index after it’s written and before there is separate usage documentation for this

class lethe.index.Index(store, path)

Access to the index of a store.

If the index file is missing, it is created in the current revision.

This object can be used as a context manager for a single transaction containing multiple calls to index, unindex and sync.

Raises UnsupportedIndexRevisionError:

if the index file exist and has a different revision than is used by the current version of Lethe


Close the index, freeing resources used.

Iterate nodes found by searching for text in all data that the index has, including node text words.

The argument is used as a query expression for SQLite FTS4 extension supporting its query syntax.


First result of short_search or None if no nodes are found.


Return the lethe.datastore.Node instance of the given uuid.

Node data is loaded from the index. The uuid must be in the exact form used for node identification. Use lethe.datastore.store.get_node in your code, it handles user-specified UUIDs.


Add the node to the index.


Index site properties.


Iterate nodes found in the index.


Load site properties from the index.

Iterate nodes with a property of given key and value.

Iterate nodes found by searching for text in their UUIDs, titles, title aliases and slugs.


Reindex all nodes.


Iterate pairs of tag name and number of tagged nodes.

The results are sorted by tag names.

Iterate nodes with the given tag.


Remove the node from the index.

exception lethe.index.UnsupportedIndexRevisionError

Exception rised when opening an index file of unsupported revision.

Previous topic

lethe.props – Key-value properties

Next topic

lethe.format – Support for formatted text

This Page