year, doc_type, department, or is_confidential) to the chunks in a vector database, then retrieve and update those fields after ingestion. You can attach metadata when you ingest files (see Create and populate a vector database), then use the methods here to browse chunks, filter them by metadata, and edit metadata in place.
Metadata rules
The same rules apply wherever metadata is accepted (ingestion request, manual chunking blocks, and the edit method below):- Metadata is a flat JSON object. Nested objects and arrays of objects are not allowed.
- Each value is a string, number, boolean, datetime, or
null. Anullvalue is treated as missing and dropped. - A metadata object has 20 or fewer keys.
- Keys are non-empty strings, recommended to be 255 characters or fewer, and cannot start with
_(reserved for system fields).
422 validation error describing the problem.
List and filter chunks
Uselist_chunks to return a paginated list of chunks from a vector database. Filter by file, by specific chunk IDs, or by metadata fields. When you provide more than one filter, results must match all of them.
Metadata filter operators:
Match a value exactly by giving it directly (
{"doc_type": "SOP"}), or use an operator object for comparisons:
Each chunk in the response includes its
chunk_id, file_id, text, metadata, hierarchy, and locations.
Edit chunk metadata
Useupdate_metadata to overwrite the metadata on chunks in a vector database. Target the chunks with either chunk_ids or file_ids, but not both. Editing is scoped to the vector database, so updating a file’s chunks here does not affect chunks of the same file in another vector database.
This operation is destructive. The metadata object you provide replaces all existing metadata on each targeted chunk, so include any fields you want to keep. To find the chunks and current metadata to edit, list them first with
list_chunks.