Vector store upsert
Description
The Vector store upsert transform stores text chunks and their embeddings as records in a vector store, through a Vector Store Connection. It is the write half of a retrieval (RAG) pipeline: typically Text Chunker, Embed Text, then this transform. Vector store search reads them back.
The same transform writes to Qdrant, Weaviate or PostgreSQL with pgvector: only the connection changes. It can create the collection on the first run, so an empty vector store is enough to get started.
A record with the ID of a stored record replaces it.
Embedding fields
The embedding field is either:
-
a field of the Vector value type, or
-
a String field with a JSON array of numbers, for example
[0.1,-0.2,0.35].
Rows whose content or embedding is empty pass on without being stored. A row whose embedding doesn’t have the configured number of dimensions fails.
Options
| Option | Description |
|---|---|
Transform name |
Name of the transform, unique within the pipeline. |
Vector store connection |
The vector store connection to write to. |
Collection |
The collection to write to: a collection in Qdrant, a collection (class) in Weaviate, a table with pgvector. |
ID field |
The field with the ID of every record. When empty, the ID is the document ID and the chunk index, |
Document ID field |
The field with the ID of the document the chunk belongs to. |
Chunk index field |
The field with the position of the chunk in its document. Needed when the ID field is empty, because the ID is then made from the document ID and the chunk index: a row without a chunk index fails. With an ID field, an empty chunk index is stored as 0. |
Content field |
The field with the text of the chunk. |
Embedding field |
The field with the embedding. |
Dimensions |
The number of dimensions of the embeddings. |
Distance metric |
How the collection compares vectors, when it is created: cosine, Euclidean (L2) or inner product. See Distance metrics and scores. |
Create collection if missing |
Create the collection, and the metadata fields it is missing, before the first record is written. When the collection exists with another number of dimensions or, on Qdrant and Weaviate, another metric, the transform fails. |
Delete document before upsert |
Delete the stored records of a document before its first record of this run is written. Use it when a new version of a document can have fewer chunks. |
Batch size |
The number of records to write at once. |
Metadata fields
The Metadata fields table stores more stream fields with every record, for example a source URL or a category, to filter on or return in Vector store search.
| Column | Description |
|---|---|
Metadata field |
The name of the field in the vector store: letters, digits and underscores, not starting with a digit. It is stored in lower case. |
Stream field |
The field with the value. |
Indexed |
Index the field for filtering, on the vector stores that need an index for it, like Qdrant. The document ID is always indexed. |
The type of a metadata field follows its stream field: String, Integer, Number or Boolean. Other types are stored as their text.
Batches and error handling
The transform writes the records in batches of the batch size. A row passes on after the batch it belongs to is written, and the rows keep their input order. Rows without a record (no content or no embedding) that wait behind a record count towards the batch size as well.
With an error hop attached, every row goes to exactly one stream: the main output when it is stored, the error hop when it is not. When a whole batch fails without telling which record caused it, the transform writes the records one by one to find the refused ones. Writing a record again only replaces it.
The error rows carry one of these codes:
-
VECTORSTOREUPSERT001: the row failed before it reached the vector store: no ID, no chunk index to make the ID from, an embedding that can’t be read or has the wrong size, a chunk index that is not a number, or the delete of its document failed. -
VECTORSTOREUPSERT002: the vector store refused the record.
Without an error hop, a failure stops the transform.
Delete document before upsert
The transform deletes the stored records of every document once per run, before it writes the first batch with a record of that document. It remembers the documents it deleted, one entry per document ID. Above one million documents in one run it stops with an error, because deleting a document a second time would delete the records the run already wrote for it.
Every copy of the transform keeps its own list, so this option needs a single copy of the transform on the Hop engine. The native Spark and Beam engines run the transform in every partition and bundle, each with its own list: one could delete the records another one just wrote for the same document. On those engines the transform stops with an error when the option is on. Delete the documents in a separate run first instead.
Qdrant and Weaviate have no transactions: when a batch fails after its documents were deleted, the records of that batch that were refused are missing until the document is loaded again.
Notes
Dimensions and Batch size accept variables.
The collection is created once per run, before any row is written: on the native Spark and Beam engines on the driver, before the job starts.