Vector
vector holds an embedding, a list of numbers with a fixed number of dimensions.
| Value | Example |
|---|---|
list of exactly dimensions numbers | [0.12, -0.5, 0.33] |
Settings
Values are lists of numbers with exactly dimensions entries. Vectors of the type bit store 8 dimensions in every integer (-128 to 127), so values have dimensions / 8 entries. A vector can be required like every property, but it can not be the items of a list. The index is described in vector , searching by vector similarity in the vector search .
Embeddings
With embedding, the vector is calculated by the API instead of being written by clients:
| Setting | Meaning |
|---|---|
provider | Required. The name of an embedding of the configuration. |
source | Required. An Expr expression which returns the text of the vector. |
dimensionsis taken from the provider and stored in the normalized definition, so the index always matches the vectors of the provider. It can be stated, but has to be the number of the provider.elementTypeis alwaysfloat.- The source only sees the element itself:
elementType, the node label or relation type, anddocument, the properties of the element like in , without internal properties and without the vectors of embeddings. A string is the text of the vector;nulland empty strings mean that the element has no text. - Requests can not write the vector,
400 Bad Requestnames the provider.PUTkeeps it. - When an element is written, its text is compared with the text before the write. A new or changed text announces the element to the background job
cron:calculate-embeddings, which runs every 5 minutes, sends the texts to the provider and writes the vectors. Until then the previous vector stays, new elements have none. No text removes the vector right away. - Writing the vector changes
updatedAt, but notupdatedBy. - If the source fails or returns something else than a string or
null, or the provider fails, the error is logged and the vector is not changed. A missing vector is calculated again on the next write of the element. - Changing the source of a schema does not calculate the vectors of existing elements again.
{ "type": "vector", "embedding": { "provider": "openai", "source": "document.title != nil && document.description != nil ? document.title + \": \" + document.description : nil" }, "index": "vector"}Storage
| Database | Stored as | Notes |
|---|---|---|
| MongoDB | array of numbers | (default) |
| Neo4j | list of numbers | with "storage": "graph" or the placement vector moved to Neo4j |
| Elasticsearch | dense_vector | search copy, indexed for the intent vector |
The search is written unless the property or the type sets "search": false. Where a property is stored is explained in .
Indices
vector, also inside objects, see the vector .
Limits
The API does not limit the number of dimensions. Elasticsearch accepts at most 4096 dimensions for dense_vector, see .
Example
Schema:
{ "type": "vector", "dimensions": 3, "similarity": "cosine", "index": "vector"}Input, the element response does not contain the hidden vector unless the schema sets "visibility": "public":
{ "data": { "embedding": [ 0.12, -0.5, 0.33 ] }}