Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -117,7 +120,7 @@ public void doAdd(List<Document> 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();
}
Expand All @@ -133,7 +136,7 @@ public Optional<Boolean> doDelete(List<String> 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());
}
Expand Down