Replace Neo4j embedding storing with new function.

The old function got replaced and might get removed in future versions.
To ensure that the store is compatible with Neo4j 5.LATEST, this commit
changes the store function for embeddings to use the 5.13+ function.

The correct baseline database version is already mentioned in the README.
This commit is contained in:
Gerrit Meier
2023-12-13 15:13:47 +01:00
committed by Christian Tzolov
parent 3fc74f95fe
commit e3a1451f19
2 changed files with 4 additions and 6 deletions

View File

@@ -235,9 +235,7 @@ public class Neo4jVectorStore implements VectorStore, InitializingBean {
SET u.id = row.id,
u += row.properties
WITH row, u
CALL db.create.setVectorProperty(u, $embeddingProperty, row.embedding)
YIELD node
RETURN count(node)
CALL db.create.setNodeVectorProperty(u, $embeddingProperty, row.embedding)
""".formatted(this.config.quotedLabel);
session.run(statement, Map.of("rows", rows, "embeddingProperty", this.config.embeddingProperty)).consume();
}

View File

@@ -36,10 +36,10 @@ import static org.assertj.core.api.Assertions.assertThat;
@EnabledIfEnvironmentVariable(named = "OPENAI_API_KEY", matches = ".+")
class Neo4jVectorStoreIT {
// Neo4j 5.12 has a bug wrt checking limits, so either 5.11 or anything higher than
// 5.12 works
// Needs to be Neo4j 5.13+, because Neo4j 5.13 deprecated the used embedding storing
// function.
@Container
static Neo4jContainer<?> neo4jContainer = new Neo4jContainer<>(DockerImageName.parse("neo4j:5.11"))
static Neo4jContainer<?> neo4jContainer = new Neo4jContainer<>(DockerImageName.parse("neo4j:5.14"))
.withRandomPassword();
List<Document> documents = List.of(