Incremental schema changes - Property Key constraint does not exist
Hi All, in our use-case the graph schema is changing over time and we have issues to incrementally add properties to the schema as we get error in the below scenario:
Below are some snippets to reproduce the above. Could you please have a look and tell us what we are doing wrong?
Day 1 - create initial schema in Gremlin console with session mode
Day 3 - adding fullName property to the person node in Gremlin console with session mode** - see day3.groovy
At this point, once we connect to the graph database,
We have checked with
We have noticed that if we stop and restart JanusGraph, the
Thank you.
- day 1: we create a graph with an initial schema: person node with
firstNameproperty. - day 2: we try adding
lastNameproperty to the person node. This still works and one can create persons with lastName - day 3: we try adding
fullNameproperty to the person node. This does not work any more asgp_traversal.addV('person').property('fullName', 'test full name')throws error:Property Key constraint does not exist for given Vertex Label [person] and property key [fullName].
Below are some snippets to reproduce the above. Could you please have a look and tell us what we are doing wrong?
Day 1 - create initial schema in Gremlin console with session mode
- see day1.groovy enclosed
- sew day2.groovy
gp_traversal.addV('person').property('lastName', 'test last name') works fine.Day 3 - adding fullName property to the person node in Gremlin console with session mode** - see day3.groovy
At this point, once we connect to the graph database,
gp_traversal.addV('person').property('fullName', 'test full name') throws Property Key constraint does not exist for given Vertex Label [person] and property key [fullName].We have checked with
printSchema() and all properties are created as expected, so gp_traversal.addV().property('fullName', 'test full name') works fine. Once we tried mgmt.getVertexLabel('person').mappedProperties() we could not see fullName property listed.We have noticed that if we stop and restart JanusGraph, the
fullName property starts working as expected but we are looking for a way to modify the schema without restarting the server.Thank you.
Solution
Hello,
you need to close graph in order to take into account new schema constraint, no need to restart server.
You can close graph with ConfiguredGraphFactory.close, then it will automatically open again with GremlinExecutorGraphBinder in JanusGraphManager.
you need to close graph in order to take into account new schema constraint, no need to restart server.
You can close graph with ConfiguredGraphFactory.close, then it will automatically open again with GremlinExecutorGraphBinder in JanusGraphManager.