Skip to main content

Collection

The Collection class represents a collection of embeddings in Chroma. It provides methods for adding, querying, updating, and deleting embeddings.

Properties

string
The name of the collection
string
The unique identifier of the collection
CollectionMetadata | undefined
Optional metadata associated with the collection
IEmbeddingFunction
The embedding function used by this collection
CollectionConfiguration | undefined
The collection’s configuration

Methods

add

Add items to the collection.
Parameters:
AddRecordsParams
required
Returns: Promise that resolves when items are added
You must provide either embeddings or documents (which will be embedded automatically using the collection’s embedding function).
Example:

query

Performs a query on the collection using the specified parameters.
Parameters:
QueryRecordsParams
required
Returns: Promise resolving to MultiQueryResponse Throws: Error if neither queryEmbeddings nor queryTexts are provided
You must provide either queryEmbeddings or queryTexts.
Example with query text:
Example with query embeddings:

get

Get items from the collection.
Parameters:
BaseGetParams
Returns: Promise resolving to GetResponse Example:

update

Update items in the collection.
Parameters:
UpdateRecordsParams
required
Returns: Promise that resolves when items are updated Example:

upsert

Upsert (insert or update) items to the collection.
Parameters:
UpsertRecordsParams
required
Same as AddRecordsParams
Returns: Promise that resolves when items are upserted Example:

delete

Deletes items from the collection.
Parameters:
DeleteParams
Returns: Promise that resolves when items are deleted Throws: Error if there is an issue deleting items Example:

count

Count the number of items in the collection.
Returns: Promise resolving to the number of items in the collection Example:

peek

Peek inside the collection to get a sample of items.
Parameters:
PeekParams
Returns: Promise resolving to the query results Throws: Error if there is an issue executing the query Example:

modify

Modify the collection name or metadata.
Parameters:
object
required
Returns: Promise resolving to the updated collection parameters Example:

fork

Forks the collection into a new collection with a new name.
Parameters:
ForkCollectionParams
required
Returns: Promise resolving to the new forked Collection object Throws: Error if there is an issue forking the collection Example: