Collection Methods
count
Return the number of records in the collection.add
Add records to the collection.Record IDs to add.
Embeddings to add. If None, embeddings are computed.
Optional metadata for each record.
Optional documents for each record.
Optional images for each record.
Optional URIs for loading images.
- ValueError: If embeddings and documents are both missing.
- ValueError: If embeddings and documents are both provided.
- ValueError: If lengths of provided fields do not match.
- ValueError: If an ID already exists.
get
Retrieve records from the collection. If no filters are provided, returns records up tolimit starting at
offset.
If provided, only return records with these IDs.
A Where filter used to filter based on metadata values.
Maximum number of results to return.
Number of results to skip before returning.
where_document
Optional[Dict[Where, Union[str, List[Dict[Where, Union[str, List[WhereDocument]]]]]]]
A WhereDocument filter used to filter based on K.DOCUMENT.
Fields to include in results. Can contain “embeddings”, “metadatas”, “documents”, “uris”. Defaults to “metadatas” and “documents”.
peek
Return the firstlimit records from the collection.
Maximum number of records to return.
query
Query for the K nearest neighbor records in the collection. This is a batch query API. Multiple queries can be performed at once by providing multiple embeddings, texts, or images.ids, where, where_document, and include parameters are applied
to all queries.
Raw embeddings to query for.
Documents to embed and query against.
Images to embed and query against.
URIs to be loaded and embedded.
Optional subset of IDs to search within.
Number of neighbors to return per query.
Metadata filter.
where_document
Optional[Dict[Where, Union[str, List[Dict[Where, Union[str, List[WhereDocument]]]]]]]
Document content filter.
Fields to include in results. Can contain “embeddings”, “metadatas”, “documents”, “uris”, “distances”. Defaults to “metadatas”, “documents”, “distances”.
- ValueError: If no query input is provided.
- ValueError: If multiple query input types are provided.
modify
Update collection name, metadata, or configuration.New collection name.
New metadata for the collection.
New configuration for the collection.
update
Update existing records by ID. Records are provided in columnar format. If provided, theembeddings, metadatas, documents, and uris lists must be the same length.
Entries in each list correspond to the same record.
embeddings are not provided, the embeddings will be computed based on documents using the collection’s embedding function.
Record IDs to update.
Updated embeddings. If None, embeddings are computed.
Updated metadata.
Updated documents.
Updated images.
Updated URIs for loading images.
upsert
Create or update records by ID.Record IDs to upsert.
Embeddings to add or update. If None, embeddings are computed.
Metadata to add or update.
Documents to add or update.
Images to add or update.
URIs for loading images.
delete
Delete records by ID or filters. All documents that match theids or where and where_document filters will be deleted.
Record IDs to delete.
Metadata filter.
where_document
Optional[Dict[Where, Union[str, List[Dict[Where, Union[str, List[WhereDocument]]]]]]]
Document content filter.
- ValueError: If no IDs or filters are provided.
Types
GetResult
Result payload for collection.get() operations. The returned records are in columnar form. Corresponding entries in each list correspond to the same record.include param
when making the get() operation.
Properties
QueryResult
Result payload for collection.query() operations. The returned records are batches of records in columnar form.include param
when making the query() operation.
Properties