chroma_query_documents
Search and retrieve documents from a Chroma collection using text queries, metadata filters, and advanced content operators for precise results.
Instructions
Query documents from a Chroma collection with advanced filtering.
Args:
collection_name: Name of the collection to query
query_texts: List of query texts to search for
n_results: Number of results to return per query
where: Optional metadata filters using Chroma's query operators
Examples:
- Simple equality: {"metadata_field": "value"}
- Comparison: {"metadata_field": {"$gt": 5}}
- Logical AND: {"$and": [{"field1": {"$eq": "value1"}}, {"field2": {"$gt": 5}}]}
- Logical OR: {"$or": [{"field1": {"$eq": "value1"}}, {"field1": {"$eq": "value2"}}]}
where_document: Optional document content filters
Examples:
- Contains: {"$contains": "value"}
- Not contains: {"$not_contains": "value"}
- Regex: {"$regex": "[a-z]+"}
- Not regex: {"$not_regex": "[a-z]+"}
- Logical AND: {"$and": [{"$contains": "value1"}, {"$not_regex": "[a-z]+"}]}
- Logical OR: {"$or": [{"$regex": "[a-z]+"}, {"$not_contains": "value2"}]}
include: List of what to include in response. By default, this will include documents, metadatas, and distances.
Input Schema
Name | Required | Description | Default |
---|---|---|---|
collection_name | Yes | ||
include | No | ||
n_results | No | ||
query_texts | Yes | ||
where | No | ||
where_document | No |
Input Schema (JSON Schema)
{
"properties": {
"collection_name": {
"title": "Collection Name",
"type": "string"
},
"include": {
"default": [
"documents",
"metadatas",
"distances"
],
"items": {
"type": "string"
},
"title": "Include",
"type": "array"
},
"n_results": {
"default": 5,
"title": "N Results",
"type": "integer"
},
"query_texts": {
"items": {
"type": "string"
},
"title": "Query Texts",
"type": "array"
},
"where": {
"anyOf": [
{
"additionalProperties": true,
"type": "object"
},
{
"type": "null"
}
],
"default": null,
"title": "Where"
},
"where_document": {
"anyOf": [
{
"additionalProperties": true,
"type": "object"
},
{
"type": "null"
}
],
"default": null,
"title": "Where Document"
}
},
"required": [
"collection_name",
"query_texts"
],
"title": "chroma_query_documentsArguments",
"type": "object"
}