Skip to content

Commit 1cdec7b

Browse files
jitokimmarkpollack
authored andcommitted
Fix Cypher syntax for vector property in Neo4jVectorStore
- Fix parameter access syntax in setNodeVectorProperty DDL statement - Define DEFAULT_TRANSACTION_SIZE for the hardcoded batch size in the delete query Fixes #1623 Signed-off-by: jitokim <[email protected]>
1 parent f6a648e commit 1cdec7b

File tree

1 file changed

+5
-2
lines changed
  • vector-stores/spring-ai-neo4j-store/src/main/java/org/springframework/ai/vectorstore

1 file changed

+5
-2
lines changed

vector-stores/spring-ai-neo4j-store/src/main/java/org/springframework/ai/vectorstore/Neo4jVectorStore.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,14 @@
4848
* @author Christian Tzolov
4949
* @author Thomas Vitale
5050
* @author Soby Chacko
51+
* @author Jihoon Kim
5152
*/
5253
public class Neo4jVectorStore extends AbstractObservationVectorStore implements InitializingBean {
5354

5455
public static final int DEFAULT_EMBEDDING_DIMENSION = 1536;
5556

57+
public static final int DEFAULT_TRANSACTION_SIZE = 10_000;
58+
5659
public static final String DEFAULT_LABEL = "Document";
5760

5861
public static final String DEFAULT_INDEX_NAME = "spring-ai-document-index";
@@ -117,7 +120,7 @@ public void doAdd(List<Document> documents) {
117120
SET u.%2$s = row.id,
118121
u += row.properties
119122
WITH row, u
120-
CALL db.create.setNodeVectorProperty(u, $embeddingProperty, row.embedding)
123+
CALL db.create.setNodeVectorProperty(u, $embeddingProperty, row[$embeddingProperty])
121124
""".formatted(this.config.label, this.config.idProperty);
122125
session.executeWrite(
123126
tx -> tx.run(statement, Map.of("rows", rows, "embeddingProperty", this.config.embeddingProperty))
@@ -137,7 +140,7 @@ public Optional<Boolean> doDelete(List<String> idList) {
137140
MATCH (n:%s) WHERE n.%s IN $ids
138141
CALL { WITH n DETACH DELETE n } IN TRANSACTIONS OF $transactionSize ROWS
139142
""".formatted(this.config.label, this.config.idProperty),
140-
Map.of("ids", idList, "transactionSize", 10_000))
143+
Map.of("ids", idList, "transactionSize", DEFAULT_TRANSACTION_SIZE))
141144
.consume();
142145
return Optional.of(idList.size() == summary.counters().nodesDeleted());
143146
}

0 commit comments

Comments
 (0)