Search code examples
gremlinjanusgraphtinkerpop3.net-core-3.1

How do i set null value to a property of a node in janusgraph?


Is it possible to set null value to a property of a node in a janusgraph through a gremlin API? We use gremlin.net 3.4.4 and .net core 3.1.


Solution

  • The currently available releases of Apache TinkerPop do not really have a concept of a null property value. This is something that may be added as an optional feature in Tinkerpop 3.5

    Currently, the non existence of a property essentially means its value is null. This approach avoids the temptation to provide a value for every possible property of every vertex and edge even if the value is null.

    As you can see below, trying to set a property value to be null will have no effect.

    gremlin> g.addV('test').property('p1',null)
    ==>v[61316]
    gremlin> g.V(61316).valueMap()
    ==>[]
    

    If you absolutely have to have a value that indicates "no value set" perhaps consider using an empty string or something like that but in general this approach is not recommended as you can test for null simply by seeing if a property exists or not on a given vertex or edge.