diff --git a/vector-stores/spring-ai-neo4j-store/src/main/java/org/springframework/ai/vectorstore/Neo4jVectorStore.java b/vector-stores/spring-ai-neo4j-store/src/main/java/org/springframework/ai/vectorstore/Neo4jVectorStore.java index 21f2e8c8a6e..2d6af4c4b85 100644 --- a/vector-stores/spring-ai-neo4j-store/src/main/java/org/springframework/ai/vectorstore/Neo4jVectorStore.java +++ b/vector-stores/spring-ai-neo4j-store/src/main/java/org/springframework/ai/vectorstore/Neo4jVectorStore.java @@ -48,11 +48,14 @@ * @author Christian Tzolov * @author Thomas Vitale * @author Soby Chacko + * @author Jihoon Kim */ public class Neo4jVectorStore extends AbstractObservationVectorStore implements InitializingBean { public static final int DEFAULT_EMBEDDING_DIMENSION = 1536; + public static final int DEFAULT_TRANSACTION_SIZE = 10_000; + public static final String DEFAULT_LABEL = "Document"; public static final String DEFAULT_INDEX_NAME = "spring-ai-document-index"; @@ -117,7 +120,7 @@ public void doAdd(List documents) { SET u.%2$s = row.id, u += row.properties WITH row, u - CALL db.create.setNodeVectorProperty(u, $embeddingProperty, row.embedding) + CALL db.create.setNodeVectorProperty(u, $embeddingProperty, row[$embeddingProperty]) """.formatted(this.config.label, this.config.idProperty); session.run(statement, Map.of("rows", rows, "embeddingProperty", this.config.embeddingProperty)).consume(); } @@ -133,7 +136,7 @@ public Optional doDelete(List idList) { MATCH (n:%s) WHERE n.%s IN $ids CALL { WITH n DETACH DELETE n } IN TRANSACTIONS OF $transactionSize ROWS """.formatted(this.config.label, this.config.idProperty), - Map.of("ids", idList, "transactionSize", 10_000)) + Map.of("ids", idList, "transactionSize", DEFAULT_TRANSACTION_SIZE)) .consume(); return Optional.of(idList.size() == summary.counters().nodesDeleted()); }