all2md.search.service
High-level orchestration for indexing and querying documents.
- all2md.search.service.compute_corpus_fingerprint(documents: Sequence[SearchDocumentInput], options: SearchOptions) str
Fingerprint a document set + index-relevant options for cache validation.
- class all2md.search.service.SearchDocumentInput
Bases:
objectRepresents a document scheduled for indexing.
- source: str | Path | bytes
- document_id: str | None = None
- source_format: Literal['auto', 'archive', 'asciidoc', 'ast', 'bbcode', 'chm', 'csv', 'docx', 'dokuwiki', 'eml', 'enex', 'epub', 'fb2', 'html', 'ini', 'ipynb', 'jinja', 'json', 'latex', 'markdown', 'mbox', 'mediawiki', 'mhtml', 'odp', 'ods', 'odt', 'openapi', 'org', 'outlook', 'pdf', 'plaintext', 'pptx', 'rst', 'rtf', 'sourcecode', 'textile', 'toml', 'webarchive', 'xlsx', 'yaml', 'zip'] | str | None = 'auto'
- metadata: Mapping[str, object] | None = None
- __init__(source: str | Path | bytes, document_id: str | None = None, source_format: Literal['auto', 'archive', 'asciidoc', 'ast', 'bbcode', 'chm', 'csv', 'docx', 'dokuwiki', 'eml', 'enex', 'epub', 'fb2', 'html', 'ini', 'ipynb', 'jinja', 'json', 'latex', 'markdown', 'mbox', 'mediawiki', 'mhtml', 'odp', 'ods', 'odt', 'openapi', 'org', 'outlook', 'pdf', 'plaintext', 'pptx', 'rst', 'rtf', 'sourcecode', 'textile', 'toml', 'webarchive', 'xlsx', 'yaml', 'zip'] | str | None = 'auto', metadata: Mapping[str, object] | None = None) None
- class all2md.search.service.SearchIndexState
Bases:
objectContainer for the active index backends.
- documents: list[tuple[Document, SearchDocumentInput]] | None = None
- vector_index: VectorIndex | None = None
- available_modes() set[SearchMode]
Get available modes of search.
- property chunk_count: int
Return number of cached chunks.
- __init__(chunks: list[Chunk], documents: list[tuple[Document, SearchDocumentInput]] | None = None, keyword_index: BM25Index | None = None, vector_index: VectorIndex | None = None) None
- class all2md.search.service.SearchService
Bases:
objectService object coordinating indexing and search execution.
Initialise the service with optional search configuration overrides.
- __init__(options: SearchOptions | None = None) None
Initialise the service with optional search configuration overrides.
- property state: SearchIndexState
Return the current in-memory search index state.
- build_indexes(documents: Sequence[SearchDocumentInput], *, modes: Iterable[SearchMode] | None = None, progress_callback: Callable[[ProgressEvent], None] | None = None) SearchIndexState
Convert sources into chunks and materialise requested indexes.
- save(directory: Path) None
Persist all active indexes to disk.
- static persisted_index_matches(directory: Path, documents: Sequence[SearchDocumentInput], options: SearchOptions) bool
Return True if a persisted index in
directoryis still current.Compares the fingerprint recorded at save time (corpus files + index-relevant options) against the fingerprint of the documents/options supplied now. A missing or unreadable manifest, or any mismatch, returns False — the caller should rebuild rather than serve a stale index.
- classmethod load(directory: Path, options: SearchOptions | None = None) SearchService
Rehydrate indexes from disk.
- search(query: str, *, mode: SearchMode | str | None = None, top_k: int = 10, progress_callback: Callable[[ProgressEvent], None] | None = None) list[SearchResult]
Execute a query using the configured index backends.