all2md.search.index

Index abstractions and manifest utilities for search backends.

class all2md.search.index.IndexManifest

Bases: object

Metadata stored alongside persisted index backends.

version: str
mode: SearchMode
index_id: str
created_at: str
options: Mapping[str, Any]
backend: Mapping[str, Any]
classmethod from_json(raw: Mapping[str, Any]) IndexManifest

Create manifest from JSON-compatible mapping.

to_json() MutableMapping[str, Any]

Return JSON-compatible manifest payload.

__init__(version: str, mode: SearchMode, index_id: str, created_at: str, options: Mapping[str, ~typing.Any]=<factory>, backend: Mapping[str, ~typing.Any]=<factory>) None
class all2md.search.index.BaseIndex

Bases: ABC

Abstract base class for all search index implementations.

Create a new index base with identifying information and stored options.

manifest_name: ClassVar[str] = 'manifest.json'
__init__(*, mode: SearchMode, index_id: str | None = None, options_snapshot: Mapping[str, Any] | None = None) None

Create a new index base with identifying information and stored options.

property chunk_count: int

Return number of chunks currently stored.

property options_snapshot: Mapping[str, Any]

Immutable view of options relevant to this index.

add_chunks(chunks: Sequence[Chunk], *, progress_callback: Callable[[ProgressEvent], None] | None = None) None

Add chunks to the index and update the backend model.

abstractmethod search(query: SearchQuery, *, top_k: int = 10) list[SearchResult]

Execute search query and return ranked results.

abstractmethod save(directory: Path) None

Persist backend files to the target directory.

abstractmethod classmethod load(directory: Path) BaseIndex

Rehydrate index from persisted files.

iter_chunks() Iterable[Chunk]

Yield stored chunks in insertion order.