> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trychroma.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Query collection

> Queries a collection using dense vector search with metadata and full-text search filtering.



## OpenAPI

````yaml https://api.trychroma.com/openapi.json post /api/v2/tenants/{tenant}/databases/{database}/collections/{collection_id}/query
openapi: 3.1.0
info:
  title: chroma-frontend
  description: ''
  license:
    name: ''
  version: 1.0.0
servers: []
security: []
paths:
  /api/v2/tenants/{tenant}/databases/{database}/collections/{collection_id}/query:
    post:
      tags:
        - Record
      summary: Query collection
      description: >-
        Queries a collection using dense vector search with metadata and
        full-text search filtering.
      operationId: collection_query
      parameters:
        - name: tenant
          in: path
          description: Tenant UUID
          required: true
          schema:
            type: string
          example: 1e30d217-3d78-4f8c-b244-79381dc6a254
        - name: database
          in: path
          description: Database name
          required: true
          schema:
            type: string
        - name: collection_id
          in: path
          description: Collection UUID
          required: true
          schema:
            type: string
          example: 1e30d217-3d78-4f8c-b244-79381dc6a254
        - name: limit
          in: query
          description: Limit for pagination
          required: false
          schema:
            type: integer
            format: int32
            minimum: 1
          example: 10
        - name: offset
          in: query
          description: Offset for pagination
          required: false
          schema:
            type: integer
            format: int32
            minimum: 0
          example: 0
      requestBody:
        description: Query request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/QueryRequestPayload'
            example:
              include:
                - documents
                - metadatas
                - distances
              n_results: 10
              query_embeddings:
                - - 0.1
                  - 0.2
                  - 0.3
        required: true
      responses:
        '200':
          description: Records matching the query
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/QueryResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Collection not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - ApiKeyAuth: []
      x-codeSamples:
        - label: Query with embeddings
          lang: typescript
          source: >-
            const results = await collection.query({ queryEmbeddings: [[0.1,
            0.2, 0.3]], nResults: 10 });
        - label: Query with text
          lang: typescript
          source: >-
            const results = await collection.query({ queryTexts: ['search
            text'], nResults: 10 });
        - label: Query with embeddings
          lang: python
          source: >-
            results = collection.query(query_embeddings=[[0.1, 0.2, 0.3]],
            n_results=10)
        - label: Query with text
          lang: python
          source: >-
            results = collection.query(query_texts=['search text'],
            n_results=10)
        - label: Query with embeddings
          lang: rust
          source: |-
            let results = collection.query(
                vec![vec![0.1, 0.2, 0.3]],
                Some(10),
                None,
                None,
                None
            ).await?;
        - label: Query with metadata filter
          lang: rust
          source: >-
            use chroma_types::{Where, MetadataExpression, MetadataComparison,
            MetadataValue, PrimitiveOperator};

            let where_clause = Where::Metadata(MetadataExpression {
                key: "category".to_string(),
                comparison: MetadataComparison::Primitive(PrimitiveOperator::Equal, MetadataValue::Str("science".to_string())),
            });

            let results = collection.query(
                vec![vec![0.1, 0.2, 0.3]],
                Some(10),
                Some(where_clause),
                None,
                None
            ).await?;
components:
  schemas:
    QueryRequestPayload:
      allOf:
        - $ref: '#/components/schemas/RawWhereFields'
        - type: object
          required:
            - query_embeddings
          properties:
            ids:
              type:
                - array
                - 'null'
              items:
                type: string
            include:
              $ref: '#/components/schemas/IncludeList'
            n_results:
              type:
                - integer
                - 'null'
              format: int32
              minimum: 0
            query_embeddings:
              type: array
              items:
                type: array
                items:
                  type: number
                  format: float
    QueryResponse:
      type: object
      required:
        - ids
        - include
      properties:
        distances:
          type:
            - array
            - 'null'
          items:
            type: array
            items:
              type:
                - number
                - 'null'
              format: float
        documents:
          type:
            - array
            - 'null'
          items:
            type: array
            items:
              type:
                - string
                - 'null'
        embeddings:
          type:
            - array
            - 'null'
          items:
            type: array
            items:
              type:
                - array
                - 'null'
              items:
                type: number
                format: float
        ids:
          type: array
          items:
            type: array
            items:
              type: string
        include:
          type: array
          items:
            $ref: '#/components/schemas/Include'
        metadatas:
          type:
            - array
            - 'null'
          items:
            type: array
            items:
              oneOf:
                - type: 'null'
                - $ref: '#/components/schemas/HashMap'
        uris:
          type:
            - array
            - 'null'
          items:
            type: array
            items:
              type:
                - string
                - 'null'
    ErrorResponse:
      type: object
      required:
        - error
        - message
      properties:
        error:
          type: string
        message:
          type: string
    RawWhereFields:
      type: object
      properties:
        where: {}
        where_document: {}
    IncludeList:
      type: array
      items:
        $ref: '#/components/schemas/Include'
    Include:
      type: string
      description: >-
        Use this enum to specify which fields should be returned when retrieving
        records.
      enum:
        - distances
        - documents
        - embeddings
        - metadatas
        - uris
    HashMap:
      type: object
      additionalProperties:
        oneOf:
          - type: boolean
          - type: integer
            format: int64
          - type: number
            format: double
          - type: string
          - $ref: '#/components/schemas/SparseVector'
          - type: array
            items:
              type: boolean
          - type: array
            items:
              type: integer
              format: int64
          - type: array
            items:
              type: number
              format: double
          - type: array
            items:
              type: string
      propertyNames:
        type: string
    SparseVector:
      type: object
      description: >-
        Represents a sparse vector using parallel arrays for indices and values.


        On deserialization: accepts both old format `{"indices": [...],
        "values": [...]}`

        and new format `{"#type": "sparse_vector", "indices": [...], "values":
        [...]}`.


        On serialization: always includes `#type` field with value
        `"sparse_vector"`.
      required:
        - indices
        - values
      properties:
        indices:
          type: array
          items:
            type: integer
            format: int32
            minimum: 0
          description: Dimension indices
        tokens:
          type:
            - array
            - 'null'
          items:
            type: string
          description: Tokens corresponding to each index
        values:
          type: array
          items:
            type: number
            format: float
          description: Values corresponding to each index
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-chroma-token

````