Skip to content

Commit 5a1b89e

Browse files
nilscebergparnmattrenetapopova
authored
Update for vector search index in 5.13 (#722)
* drop beta tag for feature, and its create and query procedures * keep beta tag on set property procedure * deprecate old set procedure in favor of new procedure with different name and signature * noted parameter validation issue (fixed in 5.13) * noted tx state issue and workaround (fixed in 5.13) --------- Co-authored-by: Matthew Parnell <[email protected]> Co-authored-by: Matthew Parnell <[email protected]> Co-authored-by: Reneta Popova <[email protected]>
1 parent 2117e90 commit 5a1b89e

File tree

1 file changed

+43
-18
lines changed

1 file changed

+43
-18
lines changed

modules/ROOT/pages/indexes-for-vector-search.adoc

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@
1010

1111
:l2-norm: image:l2.svg["l2"]-norm
1212

13-
[role=beta]
1413
[[indexes-vector]]
1514
= Vector search index
1615

17-
_Vector search indexes were released as a public beta in Neo4j 5.11._
16+
_Vector search indexes were released as a public beta in Neo4j 5.11 and general availability in Neo4j 5.13._
1817

1918
This chapter describes how to use vector indexes to perform an approximate nearest neighbor search.
2019

@@ -64,9 +63,13 @@ Returns the requested number of approximate nearest neighbor nodes and their sim
6463
| `SHOW INDEXES WHERE type = "VECTOR"`
6564
| Lists all vector indexes, see the xref:indexes-for-search-performance.adoc#indexes-list-indexes[`SHOW INDEXES`] command for details. There is no vector index filter built into `SHOW INDEXES`.
6665

66+
| Set vector property.
67+
| {link-procedures-reference}#procedure_db_create_setNodeVectorProperty[`db.create.setNodeVectorProperty`]
68+
| label:beta[] label:new[Introduced in 5.13] Update a given node property with the given vector in a more space-efficient way than directly using xref:clauses/set.adoc#set-set-a-property[`SET`]. Replaces {link-procedures-reference}#procedure_db_create_setVectorProperty[`db.create.setVectorProperty`].
69+
6770
| Set vector property.
6871
| {link-procedures-reference}#procedure_db_create_setVectorProperty[`db.create.setVectorProperty`]
69-
| Update a given node property with the given vector in a more space-efficient way than directly using xref:clauses/set.adoc#set-set-a-property[`SET`].
72+
| label:beta[] label:deprecated[] It is replaced by {link-procedures-reference}#procedure_db_create_setNodeVectorProperty[`db.create.setNodeVectorProperty`]
7073

7174
|===
7275

@@ -267,46 +270,57 @@ Removed 1 index.
267270
268271
======
269272

273+
[role=beta]
270274
[[indexes-vector-set]]
271275
== Set a vector property on a node
272276

273277
Valid vectors for use in the index must have components finitely representable in {ieee-754} _single_ precision.
274-
They are represented as properties on nodes with type `LIST<FLOAT>`.
275-
The recommended way of setting a vector property is using the link:{link-procedures-reference}#procedure_db_create_setVectorProperty[`db.create.setVectorProperty`] procedure.
276-
This procedure validates the input and sets the property as an array of {ieee-754} single precision values.
278+
They are represented as properties on nodes with the type `LIST<FLOAT>`.
279+
As of Neo4j 5.13, you can set a vector property using the {link-procedures-reference}#procedure_db_create_setNodeVectorProperty[`db.create.setNodeVectorProperty`] procedure.
280+
It validates the input and sets the property as an array of {ieee-754} single precision values.
281+
This beta procedure replaces {link-procedures-reference}#procedure_db_create_setVectorProperty[`db.create.setVectorProperty`].
282+
283+
.Signature for `db.create.setNodeVectorProperty`
284+
[source,syntax]
285+
----
286+
db.create.setNodeVectorProperty(node :: NODE, key :: STRING, vector :: LIST<FLOAT>)
287+
----
277288

278-
.Signature for `db.create.setVectorProperty`
289+
.Signature for `db.create.setVectorProperty` label:deprecated[]
279290
[source,syntax]
280291
----
281292
db.create.setVectorProperty(node :: NODE, key :: STRING, vector :: LIST<FLOAT>) :: (node :: NODE)
282293
----
283294

284-
Usually you want to define your embeddings as Cypher parameters and call `db.create.setVectorProperty` as in the following example:
295+
The following example shows how to define embeddings as Cypher parameters by matching a node and setting its vector properties using `db.create.setNodeVectorProperty`:
285296

286297
.Set a vector via `db.create.setVectorProperty`
287298
[source,cypher]
288299
----
289300
MATCH (n:Node {id: $id})
290-
CALL db.create.setVectorProperty(n, 'propertyKey', $vector)
291-
YIELD node RETURN node;
301+
CALL db.create.setNodeVectorProperty(n, 'propertyKey', $vector)
302+
RETURN node
292303
----
293304

294-
The example above matches one node and updates its embedding, but it's also possible to use a list parameter containing several MATCH criterias and embeddings, to update multiple nodes in an `UNWIND` clause.
305+
Furthermore, you can also use a list parameter containing several `MATCH` criteria and embeddings to update multiple nodes in an `UNWIND` clause.
295306
This is ideal for creating and setting new vector properties in the graph.
296307

297-
You can also set a vector property on a node using the xref:clauses/set.adoc#set-set-a-property[`SET`] command:
308+
You can also set a vector property on a node using the xref:clauses/set.adoc#set-set-a-property[`SET`] command as in the following example:
298309

299310
.Set a vector property via `SET`
300311
[source,cypher]
301312
----
302313
MATCH (node:Node {id: $id})
303314
SET node.propertyKey = $vector
304-
RETURN node;
315+
RETURN node
305316
----
306317

307-
However, Cypher stores the provided `LIST<FLOAT>` as a primitive array of {ieee-754} _double_ precision values.
308-
As a result, it takes up approximately twice as much space and it's not recommended for properties that are used in a vector index.
309-
Existing properties can be re-set using `db.create.setVectorProperty` to minimize store size, but there is a cost in the transaction log size until they are rotated away.
318+
However, Cypher stores the provided `LIST<FLOAT>` as a primitive array of {ieee-754} _double_ precision values.
319+
This takes up almost twice as much space compared to the alternative method, where you use the `db.create.setNodeVectorProperty` procedure.
320+
As a result, using `SET` for a vector index is not recommended.
321+
322+
To reduce the storage space, you can reset the existing properties using `db.create.setNodeVectorProperty`.
323+
However, this comes with the cost of an increase in the transaction log size until they are rotated away.
310324

311325
[[indexes-vector-similarity]]
312326
== Supported similarity functions
@@ -391,13 +405,24 @@ For example, you cannot have one xref:indexes-vector-similarity-euclidean[Euclid
391405
[[index-vector-issues]]
392406
== Known issues
393407

394-
The vector search index is a beta feature.
395-
The below table lists the known issues in its current implementation.
408+
As of Neo4j 5.13, the vector search index is no longer a beta feature.
409+
The following table lists the known issues and the version in which they were fixed:
396410

397411
[%header,cols="5a,d"]
398412
|===
399413
| Known issues | Fixed in
400414

415+
| Querying for a _single_ approximate nearest neighbor from an index would fail a validation check. Passing a `null` value would also provide an unhelpful exception.
416+
| Neo4j 5.13
417+
418+
| Vector index queries throw an exception if the transaction state contains changes. This means that writes may only take place *after* the last vector index query in a transaction.
419+
420+
[TIP]
421+
====
422+
To work around this issue if you need to run multiple vector index queries and make changes based on the results, you can run the queries in a `+CALL { ... } IN TRANSACTIONS+` clause to isolate them from the outer transaction's state.
423+
====
424+
| Neo4j 5.13
425+
401426
| xref:clauses/listing-procedures.adoc[`SHOW PROCEDURES`] does not show the vector index procedures:
402427

403428
* {link-procedures-reference}#procedure_db_create_setVectorProperty[`db.create.setVectorProperty`]

0 commit comments

Comments
 (0)