Text Retriever¶
TextRetriever is the default text-oriented retrieval implementation. It embeds queries on the application side, calls the raw GraphDB search primitives, and deduplicates overlapping hits.
grawiki.retrieval.text.TextRetriever
¶
Bases: Retriever
Embed queries, call DB primitives, and compose results.
The retriever is the single place where query-side embedding happens. The DB layer receives only pre-computed vectors and raw text; ranking and deduplication are concerns of this class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
db
|
GraphDB
|
Storage engine adapter used for raw search primitives. |
required |
embedding
|
Embedding
|
Shared embedding client instance. The same instance should be reused by the ingestion path to avoid loading the model twice. |
required |
retrieve
async
¶
retrieve(query, limit=5, *args, **kwargs)
Run a retrieval query and return a list of hits.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
Raw query text. |
required |
limit
|
int | None
|
Maximum hits per label. Overrides the default limit if provided. |
5
|
Returns:
| Type | Description |
|---|---|
list[NodeHit]
|
Flat, deduplicated hit list across all requested labels. |
fulltext
async
¶
fulltext(query, *, labels, limit=10)
Run a full-text search across the given node labels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
Raw query text forwarded to the DB full-text index. |
required |
labels
|
list[str]
|
Node labels to search. |
required |
limit
|
int
|
Maximum hits per label. |
10
|
Returns:
| Type | Description |
|---|---|
list[NodeHit]
|
Flat, deduplicated hit list across all requested labels. |
vector
async
¶
vector(query, *, labels, limit=10)
Embed a query and run a vector similarity search.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
Raw query text. The retriever embeds it using :attr: |
required |
labels
|
list[str]
|
Node labels to search. |
required |
limit
|
int
|
Maximum hits per label. |
10
|
Returns:
| Type | Description |
|---|---|
list[NodeHit]
|
Flat, deduplicated hit list with higher scores representing more relevant matches. |
Raises:
| Type | Description |
|---|---|
ValueError
|
Raised when the embedding returns an empty result. |