Search code examples
gremlintinkerpopgremlin-server

Properties not added to a vertex on g.addV()


Running Gremlin Server on my local machine with the following settings:

gremlin.graph=org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph
gremlin.tinkergraph.vertexIdManager=ANY
gremlin.tinkergraph.vertexPropertyIdManager=UUID
gremlin.tinkergraph.defaultVertexPropertyCardinality=list

When I run the query:

g.addV('Root')
.property(id,'15c9a352-2261-4ba1-8f54-96d6ac0c1a47')
.property('linkId','15c9a352-2261-4ba1-8f54-96d6ac0c1a47')
.property('name','Root')

I receive the following response:

{"id":"15c9a352-2261-4ba1-8f54-96d6ac0c1a47","label":"Root","type":"vertex","properties":{}}

The properties were not added and when I get the stored vertex it also doesn't contain the properties.

When I run the following query:

graph.addVertex(
id, 'b83c53d4-6bfb-4b8c-a4f2-02a8c0f4a867', 
label, 'Root', 
'linkId', 'b83c53d4-6bfb-4b8c-a4f2-02a8c0f4a867', 
'name', 'root')

I get the following response:

{
   "id":"b83c53d4-6bfb-4b8c-a4f2-02a8c0f4a867",
   "label":"Root",
   "type":"vertex",
   "properties":{
      "linkId":[
         {
            "id":"ad8c4ace-7752-40f5-a531-4e03e2083a06",
            "value":"b83c53d4-6bfb-4b8c-a4f2-02a8c0f4a867"
         }
      ],
      "name":[
         {
            "id":"b16492c1-7a43-421d-aa8c-d8f51b2a358e",
            "value":"root"
         }
      ]
   }
}

I understand that the first query is using g = graph.traversal() and the second is using the graph object.

Why would there be a difference in outcomes for properties on adding a vertex?

Could there be a setting I am missing on my gremlin server or is there something wrong with my query?


Solution

  • The solution was to change the property gremlin.tinkergraph.defaultVertexPropertyCardinality to set

    With my gremlin server settings now the following:

    gremlin.graph=org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph
    gremlin.tinkergraph.vertexIdManager=UUID
    gremlin.tinkergraph.vertexPropertyIdManager=UUID
    gremlin.tinkergraph.defaultVertexPropertyCardinality=set