Skip to main content
Alongside semantic query, a SessionIndex supports deterministic retrieval — exact lookups that run with no embedding and no similarity ranking. Use it when you know precisely which documents you want: fetch by id, filter by metadata, and group chunks back into their parent unit. All of it runs locally on the session.
Requires moss 1.6.0+ (which pulls inferedge-moss-core 0.19.0). This is the Python counterpart to the Swift exact/graph retrieval surface.
In the examples below, session is a SessionIndex opened with session = await client.session(index_name, model_id=...). The deterministic fetches are configured through GetDocumentsOptions passed to session.get_docs; parent grouping is also available on semantic session.query via QueryOptions.group_by.

Fetch by id (exact, ordered)

Returns documents in the exact order requested; missing ids are skipped.

Fetch by metadata (filter + sort)

Pass a filter — the same dict shape used for metadata filtering on queries — to fetch every matching document, with no query vector and no ranking. sort_by orders by a metadata field (numeric-aware); ascending defaults to True.

Group chunks into their parent record

When a logical record (a long document, an article, a transcript) is stored as several sibling chunks that share a parent id, ParentGrouping collapses them into one result — sibling text assembled in order_field order (numeric-aware), the best score kept.
Grouping also works on semantic query via QueryOptions.group_by, which collapses sibling hits into one result per record:
For complete records, prefer get_docs(..., group_by=...) — it groups over the full matching set. On the semantic query path, grouping over-fetches candidates and returns top_k records, but a record whose siblings fall outside the fetched window may still be partially assembled; raise top_k for wider coverage.

Mixing exact and semantic

There’s no blended call — run the two and combine. A common pattern: semantic query to rank candidates, then get_docs(doc_ids=...) to pull the exact, fully-populated records (with payloads) for the winners.

Structured payload

Carry the full verbatim record alongside the embedded text.

Metadata filtering

The filter dict shape, shared with queries.