0
votes

How can I retrieve all vertex properties starting from the root vertex in Gremlin query?

We have the following structure:
Root Vertex: Employee

Edges: EdCompany, EdDepartment, EdRole
Vertices: Company, Department, Role

graph example

We are trying to receive the data of the other vertices joined with the root vertex. Somethink like this:

{
    "employee": [
        {
            "id": "1",
            "label": "Employee",
            "type": "vertex",
            "properties": { ... },
            "company": { 
                "id": "A220",
                "label": "Company",
                "type": "vertex",
                "properties": { ... }, 
            },
            "department": { ... },
            "edge": { ... }
        },
        { ... }
    ]
}

We have tried that query but return a complex JSON:

g.V().hasLabel("Employee").inE().outV().tree()

EDIT:

We have also tried the query suggested by Kelvin:

g.V().hasLabel("Employee").inE().outV().tree().by(valueMap())  

last test image screen

Stacktrace:
Failure in submitting query: g.V().hasLabel("Employee").inE().outV().tree().by(valueMap()): Server serialization error: ActivityId : 29f4b64e-c476-44b8-8e35-a07dd31d4242 ExceptionType : GraphSerializeException ExceptionMessage : Gremlin Serialization Error: GraphSON V1_0 serializer cannot serialize object of type: MapField to a primitive value to perform the desired Gremlin step

1

1 Answers

1
votes

If all you need is the tree from the root you can just add a by(valueMap()) to your query to get the properties included as well. Such as:

g.V().hasLabel("Employee").
  inE().
  outV().
  tree().
    by(valueMap())