Skip to content

API Reference parrot.stores.lancedb

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.stores.lancedb

View source

LanceDB backend: lifecycle, collection setup and compatibility normalization.

Query methods are declared here but implemented by TASK-3064 (vector) and TASK-3065 (FTS/hybrid). The SDK is imported lazily inside methods so this module stays importable without ai-parrot-embeddings[lancedb].

Alias AbstractStore

Re-exported from parrot.stores.AbstractStore.

Alias CollectionManifest

Re-exported from parrot.stores.lancedb_models.CollectionManifest.

Alias LanceDBConfig

Re-exported from parrot.stores.lancedb_models.LanceDBConfig.

Alias LanceDBHybridHit

Re-exported from parrot.stores.lancedb_models.LanceDBHybridHit.

Class LanceDBStore

Embedded vector, full-text and hybrid store over a local directory.

Parameter Type Default Description
embedding_model Union[dict, str] None
embedding Union[dict, Callable] None
**kwargs Any {}

Method LanceDBStore.connection

Open the directory and return (connection, default_table_or_none).

Idempotent. Never creates or replaces a collection.

connection() -> tuple

Returns: tuple

Method LanceDBStore.get_vector

Return the already-open default table, or raise.

get_vector(metric_type: str = None, **kwargs: Any)

Parameter Type Default Description
metric_type str None
**kwargs Any {}

Raises:

  • RuntimeError — the store is not connected to an existing collection. This accessor performs no I/O.

Method LanceDBStore.get_connection

get_connection() -> Any

Returns: Any

Method LanceDBStore.create_collection

Create the Arrow schema and the native FTS index when missing.

Idempotent on a compatible existing collection (including finishing FTS index preparation on retry). A failed FTS setup leaves an explicit initialization error, never a successful searchable collection. Never overwrites an existing table.

create_collection(collection: str) -> None

Parameter Type Default Description
collection str

Method LanceDBStore.prepare_embedding_table

Legacy-compatible alias for :meth:create_collection.

Accepts conn=None or this store's own connection; default column labels; use_jsonb=True as a compatibility-only flag (no JSONB database is created). Rejects drop_columns=True, a foreign connection, custom column labels and non-empty additional_columns. Native FTS preparation is mandatory even when create_all_indexes is False — this backend never requests an ANN index.

prepare_embedding_table(tablename: str, conn: Any = None, embedding_column: str = 'embedding', document_column: str = 'document', metadata_column: str = 'cmetadata', dimension: int = None, id_column: str = 'id', use_jsonb: bool = True, drop_columns: bool = False, create_all_indexes: bool = True, **kwargs: Any) -> None

Parameter Type Default Description
tablename str
conn Any None
embedding_column str 'embedding'
document_column str 'document'
metadata_column str 'cmetadata'
dimension int None
id_column str 'id'
use_jsonb bool True
drop_columns bool False
create_all_indexes bool True
**kwargs Any {}

Method LanceDBStore.disconnect

Idempotent shutdown; waits for this store's in-flight operations.

disconnect() -> None

Method LanceDBStore.similarity_search

Exact cosine search. Scores are RAW DISTANCES: lower is better.

similarity_search(query: str, collection: Union[str, None] = None, limit: int = 2, similarity_threshold: float = 0.0, search_strategy: str = 'auto', metadata_filters: Union[dict, None] = None, include_parents: bool = False, **kwargs: Any) -> list

Parameter Type Default Description
query str
collection Union[str, None] None
limit int 2
similarity_threshold float 0.0
search_strategy str 'auto'
metadata_filters Union[dict, None] None
include_parents bool False
**kwargs Any {}

Returns: list

Raises:

  • ValueError — non-positive/boolean/non-integer limit, out-of-range threshold, or an unsupported search_strategy.
  • LookupError — the collection does not exist.

Method LanceDBStore.from_documents

Prepare the collection, add the documents and return this store.

from_documents(documents: List[Any], collection: Union[str, None] = None, **kwargs: Any) -> Callable

Parameter Type Default Description
documents List[Any]
collection Union[str, None] None
**kwargs Any {}

Returns: Callable

Method LanceDBStore.add_documents

Upsert documents into an existing prepared collection.

add_documents(documents: List[Any], collection: Union[str, None] = None, **kwargs: Any) -> None

Parameter Type Default Description
documents List[Any]
collection Union[str, None] None
**kwargs Any {}

Raises:

  • LookupError — the collection does not exist.
  • ValueError — conflicting or duplicate IDs, invalid metadata, or an invalid embedding vector, for ANY document in the input — validated for the whole input before any batch is written.

Method LanceDBStore.delete_documents

Delete by document identity or by pk + values. Returns rows removed.

delete_documents(documents: Any = None, pk: str = 'source_type', values: Any = None, table: str = None, schema: str = None, collection: str = None, **kwargs: Any) -> int

Parameter Type Default Description
documents Any None
pk str 'source_type'
values Any None
table str None
schema str None
collection str None
**kwargs Any {}

Returns: int

Raises:

  • ValueError — empty filter, missing selector, or conflicting selectors.

Method LanceDBStore.delete_documents_by_filter

Delete by compiled metadata predicate (no parent-exclusion clause). Returns rows removed.

delete_documents_by_filter(search_filter: dict, table: str = None, schema: str = None, collection: str = None, **kwargs: Any) -> int

Parameter Type Default Description
search_filter dict
table str None
schema str None
collection str None
**kwargs Any {}

Returns: int

Method LanceDBStore.fulltext_search

Native BM25 lexical search. Constructs no embedding model.

Scores are native BM25 (higher is better). The inherited SearchResult.distance alias is therefore numerically BM25 and is NOT a distance — this limitation is documented, not a bug.

fulltext_search(query: str, collection: Union[str, None] = None, limit: int = 10, metadata_filters: dict[str, Any] | None = None, include_parents: bool = False, **kwargs: Any) -> list

Parameter Type Default Description
query str
collection Union[str, None] None
limit int 10
metadata_filters dict[str, Any] | None None
include_parents bool False
**kwargs Any {}

Returns: list

Method LanceDBStore.hybrid_search

Native vector/FTS fusion. Returns LanceDBHybridHit; no distance alias.

hybrid_search(query: str, collection: Union[str, None] = None, limit: int = 10, metadata_filters: dict[str, Any] | None = None, include_parents: bool = False, **kwargs: Any) -> list

Parameter Type Default Description
query str
collection Union[str, None] None
limit int 10
metadata_filters dict[str, Any] | None None
include_parents bool False
**kwargs Any {}

Returns: list

Raises:

  • Exception — whatever the SDK (or the provider) raises when either leg fails. There is no fallback to a single leg — a failed hybrid fails the whole call (spec §8 whole-origin-failure answer).

Method LanceDBStore.mmr_search

Always raises: v1 supports exact similarity search only.

mmr_search(**kwargs: Any) -> list

Parameter Type Default Description
**kwargs Any {}

Returns: list

Alias MutationCoordinator

Re-exported from parrot.stores.lancedb_concurrency.MutationCoordinator.

Alias RESERVED_METADATA_KEY

Re-exported from parrot.stores.lancedb_models.RESERVED_METADATA_KEY.

Alias STANDARD_BOOL_FIELDS

Re-exported from parrot.stores.lancedb_models.STANDARD_BOOL_FIELDS.

Alias STANDARD_STRING_FIELDS

Re-exported from parrot.stores.lancedb_models.STANDARD_STRING_FIELDS.

Alias SearchResult

Re-exported from parrot.models.stores.SearchResult.

Alias build_arrow_schema

Re-exported from parrot.stores.lancedb_models.build_arrow_schema.

Alias combine

Re-exported from parrot.stores.lancedb_filters.combine.

Alias compile_metadata_filter

Re-exported from parrot.stores.lancedb_filters.compile_metadata_filter.

Alias embedding_fingerprint

Re-exported from parrot.stores.lancedb_models.embedding_fingerprint.

Alias namespaced_id

Re-exported from parrot.stores.lancedb_models.namespaced_id.

Alias parent_exclusion_clause

Re-exported from parrot.stores.lancedb_filters.parent_exclusion_clause.

Alias record_id_for

Re-exported from parrot.stores.lancedb_models.record_id_for.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally