Skip to main content

Upsert Vectors using UpsertV  

Create new vector embeddings or update existing ones with insert-or-update semantics.
UpsertV is a traversal step that operates on an existing traversal context. The type comes from the preceding traversal (V<Type>), not from the upsert call itself. If the traversal returns existing vectors, they are updated; if no vectors are found, a new vector is created.
Vector data is required for UpsertV. You can provide vector data as:
  • A literal array of floats (e.g., [0.1, 0.2, 0.3])
  • The Embed() function to generate embeddings from text
  • A variable containing vector data

Example 1: Basic vector upsert with properties

Here’s how to run the query using the SDKs or curl

Example 2: Upsert vector using the Embed function

You can use the built-in Embed function to generate embeddings from text.
All vectors in a vector type must have the same dimensions. If you change your embedding model, the new vectors will have different dimensions and will cause an error. Ensure you use the same embedding model consistently for all vectors.
Here’s how to run the query using the SDKs or curl

Example 3: Complex operation with nodes, edges, and vectors

Here’s how to run the query using the SDKs or curl

How Upsert differs from Add

When updating, UpsertV merges properties: it updates specified properties while preserving any existing properties that aren’t included in the upsert. The vector data itself is also updated.