hoops_ai.ml.embeddings.VectorStore
- class hoops_ai.ml.embeddings.VectorStore
Bases:
ABCINTERFACE vector storage supporting CRUD operations and filtering.
Implementations should provide efficient storage and retrieval of high-dimensional vectors with support for similarity search, metadata filtering, and CRUD operations.
- abstract close()
Close the vector store and release resources.
- Return type:
None
- abstract count()
Return total number of vectors in the store.
- Returns:
Number of stored vectors
- Return type:
- abstract delete(ids)
Delete vectors by their ids.
- abstract get_ids()
Return list of all indexed vector IDs.
- Returns:
List of all vector IDs currently in the store
- Return type:
List[str]
- abstract iter_metadata()
Yield the metadata dict for every stored record.
- abstract classmethod load(path)
Load a persisted vector store from disk or restore connection.
For local stores (e.g., FAISS): Deserializes index and metadata from file. For cloud stores (e.g., Weaviate, Qdrant): Restores connection to existing index.
- Parameters:
path (str) – File path for local stores, or identifier for cloud stores
- Returns:
Restored vector store instance
- Return type:
- abstract query(query_vector, top_k=10, filters=None, include_metadata=True)
Search for similar vectors.
- Parameters:
- Returns:
List of VectorHit objects sorted by similarity score (descending)
- Return type:
List[VectorHit]
- abstract save(path)
Persist the vector store to disk or save connection configuration.
For local stores (e.g., FAISS): Serializes index and metadata to a file. For cloud stores (e.g., Weaviate, Qdrant): May save connection config or be a no-op.
- Parameters:
path (str) – File path for local stores, or identifier for cloud stores
- Return type:
None
- abstract update_record_metadata(record_id, updates)
Merge updates into the metadata dict of an existing record.
Returns True if the record exists and was updated, False if not found.
- abstract upsert(records)
Insert or update vector records.
- Parameters:
records (Sequence[VectorRecord]) – Sequence of VectorRecord objects to store
- Return type:
None