cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Using DynamicLabels in Neo4jRepository SaveAll

Hi there,

I am trying to insert/update nodes with Neo4jNodeRepository SaveAll function and add labels with the @DynamicLabels annotation. All nodes are inserted into the database but without the labels.
When I use the Save function the dynamic Labels are added to the nodes.

When I look in de implementation of the SaveAll function in Neo4jTemplate.java, there seems to be no implementation for Dynamic labels. In de Save (saveImpl) there is a call to determineDynamicLabels. Is this by design? Is it possible to add dynamic labels to the saveAll function as well?

Thanks in advance,

Fedor

5 REPLIES 5

Thanks for pointing me to this. You are right, it was "just missing". I targeted it with this issue Dynamic labels won't get persisted on saveAll. · Issue #2110 · spring-projects/spring-data-neo4j · G... and it will get included in the service release that will get published later today.

Thanks Gerrit for your quick response. I'm glad we can use de save all with dynamic labels!

Is there a big penalty in using save all with dynamic labels? Internally it seems to be calling the normal save, would it be better for a large import to save labels of the same type in one go, without the use of dynamic labels, in terms of performance?

The save/update for dynamic labels has to happen in a call for each provided entity. Otherwise we cannot set and remove the labels on a per node base. At the moment the old labels get loaded from the database directly prior the actual (single) save call to create the correct label patch (REMOVE / SET) part for the save statement.

Hi @gerrit.meier . I'm using dynamic labels and running into a major ReactiveNeo4jRepository.save performance issue that I believe relates to the below query, generated by the Spring Data Neo4j package.

MATCH (n) WHERE n.id = $__id__ UNWIND labels(n) AS label WITH label WHERE NOT (label IN $__staticLabels__) RETURN collect(label) AS __nodeLabels__

From my testing this will cause a full node scan, as it can't leverage a schema index if it's not using a label in the match statement. Am I correct in that and is there a way to avoid it?

I'm using spring boot v 2.4.4 and spring-data-neo4j v 6.0.6

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

All the sessions of the conference are now available online