Category Archives: Database

Create Vertex If Does Not Exist – Gremlin Query – Titan

Create Vertex If Does Not Exist - Gremlin Query - Titan

Create Vertex If Does Not Exist – Gremlin Query – Titan

Create Vertex If Does Not Exist - Gremlin Query - Titan

Create Vertex If Does Not Exist Return a vertex with given label and property. If the vertex does not exist, a new vertex is created and returned to vertexObject. vertexObject = g.V().hasLabel(‘VERTEX_LABEL’).has(‘property’,’value’).tryNext().orElseGet{ graph.addVertex(label, ‘VERTEX_LABEL’, ‘property’, ‘value’); }; Related Links:

Query/Access Root Level Properties and Nested Properties of Vertex in Single Query – Gremlin Query – Titan

Query/Access Root Level Properties and Nested Properties of Vertex in Single Query - Gremlin Query - Titan

Query/Access Root Level Properties and Nested Properties of Vertex in Single Query – Gremlin Query – Titan

Query/Access Root Level Properties and Nested Properties of Vertex in Single Query - Gremlin Query - Titan

Gremlin Query: g.V().hasLabel(‘TEST_LABEL’).has(‘_id’,’xxxxxxxxxxxxxx’).as(‘v’) .select(‘v’).valueMap(true).as(‘properties’) .select(‘v’).properties(‘nestedPropertiesKey’).valueMap().as(‘nestedProperties’) .select(‘properties’,’nestedProperties’) Sample Response: { “properties”:{ “attr1″:”value1” }, “nestedProperties”:{ “nestedAttr1″:”nestedValue1” } } Related Links: