Overview
TheSolVecCollection class represents a single vector collection. The API is intentionally identical to Pinecone’s Index class for easy migration.
You don’t instantiate this class directly. Instead, use SolVec.collection() to get or create a collection.
Constructor
Methods
upsert()
Insert or update vectors in the collection. If a vector with the same ID exists, it will be updated.Parameters
List of vectors to upsert. Each vector can be either:Dictionary format:
id(str, required) - Unique identifier for the vectorvalues(list[float], required) - The embedding vectormetadata(dict, optional) - Additional metadata to store with the vector
UpsertRecord dataclass:Returns
Object containing:
upserted_count(int) - Number of vectors successfully upserted
Raises
ValueError- If vector dimensions don’t match the collection’s dimensions
Examples
query()
Query for nearest neighbors using vector similarity search.Parameters
Query embedding vector. Must match the collection’s dimensions.
Number of results to return. Results are sorted by score in descending order.
Metadata filter dictionary. Only vectors whose metadata matches ALL key-value pairs will be returned.Example:
{"category": "memory", "user_id": "123"}Whether to include metadata in the response. Set to
False to reduce response size.Whether to include the vector values in the response. Usually not needed for most use cases.
Returns
Object containing:
matches(list[QueryMatch]) - List of matching vectors sorted by score (highest first)namespace(str) - The collection name
QueryMatch contains:id(str) - Vector IDscore(float) - Similarity scoremetadata(dict) - Vector metadata (ifinclude_metadata=True)values(list[float] | None) - Vector values (ifinclude_values=True)
Raises
ValueError- If query vector dimensions don’t match the collection’s dimensions
Examples
delete()
Delete vectors by ID.Parameters
List of vector IDs to delete. Non-existent IDs are silently ignored.
Returns
NoneExample
fetch()
Fetch specific vectors by ID.Parameters
List of vector IDs to fetch.
Returns
Dictionary containing:
vectors(dict) - Dictionary mapping IDs to vector objectsnamespace(str) - The collection name
id(str) - Vector IDvalues(list[float]) - The embedding vectormetadata(dict) - Vector metadata
Example
describe_index_stats()
Get collection statistics and metadata.Returns
Object containing:
vector_count(int) - Total number of vectors in the collectiondimension(int) - Vector dimensionsmetric(DistanceMetric) - Distance metric being usedname(str) - Collection namemerkle_root(str) - Current Merkle root hash for integrity verificationlast_updated(int) - Unix timestamp of last updateis_frozen(bool) - Whether the collection is frozen (read-only)
Example
verify()
Verify collection integrity against on-chain Merkle root.Returns
Object containing:
verified(bool) - Whether verification succeededon_chain_root(str) - Merkle root stored on Solanalocal_root(str) - Locally computed Merkle rootmatch(bool) - Whether roots matchvector_count(int) - Number of vectors verifiedsolana_explorer_url(str) - Link to Solana Explorer for the verification transactiontimestamp(int) - Verification timestamp in milliseconds
Example
Instance Attributes
Collection name
Vector dimensions
Distance metric (cosine, euclidean, or dot)
Solana network (mainnet-beta, devnet, or localnet)
Path to wallet keypair file