Search for items within a namespace prefix.
search(
self,
namespace_prefix: tuple[str, ...],
,
*,
query: str | None = None,
filter: dict[str, Any] | None = None,
limit: int = 10,
offset: int = 0,
refresh_ttl: bool | None = None
) -> list[SearchItem]Basic filtering:
# Search for documents with specific metadata
results = store.search(
("docs",),
filter={"type": "article", "status": "published"}
)
Natural language search (requires vector store implementation):
# Initialize store with embedding configuration
store = YourStore( # e.g., InMemoryStore, AsyncPostgresStore
index={
"dims": 1536, # embedding dimensions
"embed": your_embedding_function, # function to create embeddings
"fields": ["text"] # fields to embed. Defaults to ["$"]
}
)
# Search for semantically similar documents
results = store.search(
("docs",),
query="machine learning applications in healthcare",
filter={"type": "research_paper"},
limit=5
)
Natural language search support depends on your store implementation and requires proper embedding configuration.
| Name | Type | Description |
|---|---|---|
namespace_prefix* | tuple[str, ...] | Hierarchical path prefix to search within. |
query | str | None | Default: NoneOptional query for natural language search. |
filter | dict[str, Any] | None | Default: NoneKey-value pairs to filter results. |
limit | int | Default: 10Maximum number of items to return. |
offset | int | Default: 0Number of items to skip before returning results. |
refresh_ttl | bool | None | Default: NoneWhether to refresh TTLs for the returned items. If no TTL is specified, this argument is ignored. |