There is no way yet to enforce that at the neo level we plan to add such optional constraints later on.
What works in such import situations is to have a set of rules written in cypher that check the valid model and return offenders Then you can use a cypher query to fix your model Eg by deleting wrong relations and creating the correct ones with their data Much like jqassistant does for source code on top of neo4j Sent from mobile device Am 04.07.2014 um 21:07 schrieb Liliana Ziolek <[email protected]>: > I came across this as a classic PEBKAC issue when importing the data, but the > resulting exception on SDN was a bit obscure and I ended spending quite a bit > of time time trying to work out what's wrong. It made me think of a better > way of handling this issue at the data import step. > > What happened was that I was importing data from a CSV file, and with the > "helpful" Excel autocompletion I ended up with something like: > Node11,LinkedNodeX > Node11,LinkedNodeZ > > instead of the intended: > Node11,LinkedNodeX > Node1,LinkedNodeZ > > The result was that rather than having one relationship R between each pair, > there were 2 relationships R going out of Node11 - which is never correct in > my domain. Then when I was trying to retrieve a number of nodes via SDN I was > getting an exception: > java.lang.IllegalArgumentException: Cannot obtain single field value for > field 'to' > at > org.springframework.data.neo4j.fieldaccess.RelatedToSingleFieldAccessorFactory$RelatedToSingleFieldAccessor.getValue(RelatedToSingleFieldAccessorFactory.java:94) > at > org.springframework.data.neo4j.fieldaccess.DefaultEntityState.getValue(DefaultEntityState.java:97) > [...] > > The problem was that despite having a data model in Neo4j and some unique > constraints on node properties, I managed to mess up my data via cypher on > the relationship level. > > Note it's not a "I don't want 2 relationships of type X between A&B", but "If > A has outgoing relationship X to B, then it cannot have outgoing relationship > X going to C". As far as I understand, using MERGE in my queries would deal > with the former case, but I can't quite figure out how to write an update, or > place a constraint, that would fail in the latter case. > Obviously if I was inserting the data with SDN this would never have happened > as I have a correct mapping on the POJO, but is there a way to enforce this > on the Neo4j level, so that even if I messed up my cypher queries I can't > affect data integrity? > > Thanks > -- > You received this message because you are subscribed to the Google Groups > "Neo4j" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Neo4j" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
