New Search API Available: Chroma Cloud users can now use the powerful Search API for advanced hybrid search capabilities with better filtering, ranking, and batch operations.
- Python
- TypeScript
You can query a Chroma collection to run a similarity search using the Chroma will use the collection’s embedding function to embed your text queries, and use the output to run a vector similarity search against your collection.Instead of provided By default, Chroma will return 10 results per input query. You can modify this number using the The You can also retrieve records from a collection by using the Both
.query method:query_texts, you can provide query embeddings directly. You will be required to do so if you also added embeddings directly to your collection, instead of using its embedding function. If the provided query embeddings are not of the same dimensions as those in your collection, an exception will be raised.n_results argument:ids argument lets you constrain the search only to records with the IDs from the provided list:.get method. It supports the following arguments:ids- get records with IDs from this list. If not provided, the first 100 records will be retrieved, in the order of their addition to the collection.limit- the number of records to retrieve. The default value is 100.offset- The offset to start returning results from. Useful for paging results with limit. The default value is 0.
query and get have the where argument for metadata filtering and where_document for full-text search and regex:Results Shape
Chroma returns.query and .get results in columnar form. You will get a results object containing lists of ids, embeddings, documents, and metadatas of the records that matched your .query or get requests. Embeddings are returned as 2D-numpy arrays..query results also contain a list of distances. These are the distances of each of the results from your input queries. .query results are also indexed by each of your input queries. For example, results["ids"][0] contains the list of records IDs for the results of the first input query.Choosing Which Data is Returned
By default,.query and .get always return the documents and metadatas. You can use the include argument to modify what gets returned. ids are always returned: