---
title: "Finds chunks related to a message using lexical search."
method: POST
path: "/collections/{collection_id}/chunks/search"
tags: ["Collections"]
---

# Finds chunks related to a message using lexical search.

`POST /collections/{collection_id}/chunks/search`

## Request

- Base URL: `https://h2ogpte.genai.h2o.ai/api/v1`
- URL: `https://h2ogpte.genai.h2o.ai/api/v1/collections/{collection_id}/chunks/search`
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/h2o/apis/h2ogpte-rest-api/docs/collections/:collection_id/chunks/search/post.ts> (a function with typed inputs; its response is checked against the schema)

Finds chunks related to a message using lexical search.
Chunks are sorted by relevance and similarity score to the message.

## Path parameters

- `collection_id` string, required

## Request body

- object
  - `query` string, required: Question or imperative from the end user to search a collection for.
  - `topics` string[], required: A list of document_ids used to filter which documents in the collection to search.
  - `offset` integer: How many chunks to skip before returning chunks.
  - `limit` integer: How many chunks to return.

## Response `200`

Successful operation

- ChunkSearchResult[]
  - `text` string, required: The text represented by the chunk
  - `id` integer, required: The identifier of the chunk
  - `name` string, required
  - `size` integer, required: The size in bytes.
  - `pages` string, required
  - `start_time` number, double, nullable: For audio/video transcript chunks, the start time in seconds of the chunk's content, located within the document's diarization segments: exact at a speaker segment's boundary, and linearly interpolated by character position when a segment spans multiple chunks. Populated for transcript chunks returned by the get_chunks endpoint (including a mid-segment continuation chunk); null for non-transcript chunks and documents without captured segment timestamps. Chunk search and match results do not carry per-chunk times — use get_chunks, or get_audio_timestamps for full exact per-segment timing.
  - `end_time` number, double, nullable: For audio/video transcript chunks, the end time in seconds of the chunk's content, located within the document's diarization segments: exact at a speaker segment's boundary (so the final chunk ends at the true segment end) and linearly interpolated by character position within a segment that spans multiple chunks, so it never overshoots the text the chunk holds. Populated for transcript chunks returned by the get_chunks endpoint; null for non-transcript chunks and documents without captured segment timestamps. Chunk search and match results do not carry per-chunk times.
  - `topic` string, required
  - `score` number, double, required

## Other responses

- `400`: Bad request
- `401`: Unauthorized - Invalid or missing API key
- `default`: Unexpected error

---

[API](https://skmtc.dev/h2o/apis/h2ogpte-rest-api.md) - [All operations](https://skmtc.dev/h2o/apis/h2ogpte-rest-api/llms.txt) - [OpenAPI document](https://skmtc.dev/h2o/apis/h2ogpte-rest-api/revisions/a82a117320f4?raw)
