Graph DB Gremlin query for nested properties

Viewed 38

I am storing the below data in azure cosmos graph db.

 "properties": {
        "A": {
          "value": "prop1 new value"
        },
        "settings": {
          "DigitalInput": {
            "Input1": {
              "nTransIn1": {
                "tagName": {
                  "value": ""
                }
              }
            },
            "Input2": {
              "nTransIn2": {
                "tagName": {
                  "value": ""
                }
              }
            }

When I am trying to query by single property

g.V().has('s_objectId',within('9d8cf5c6-7b5f-4d0b-af70-bf516f219d73')).
valueMap("p_A")

is giving expected output but how to retrieve with property 'settings' which has nested properties. When I try

g.V().has('s_objectId',within('9d8cf5c6-7b5f-4d0b-af70-bf516f219d73')).
valueMap("p_settings")

it is not giving the correct output as the setting property is stored like below in graph database

 "p_settings.DigitalInput.Input1.nTransIn1.tagName": [
        {
          "id": "6057e448-a2e8-48e4-820f-5396003bdcae",
          "value": ""
        }
      ],
1 Answers

Your queries and sample data seem to use different field names. It would be helpful if you could add to the question an addV step that creates the structure you are using in a way that can be tested with TinkerGraph.

In general with Gremlin, the way to access map structures is to select your way into it. Something like

valueMap("p_A").select("p_settings")
Related