0

I have the following query to insert two vertices and create an parent edge. I use g.V('001').repeat(out('parent')).emit().dedup().toList() to search the parent for node 001.

However, I don't see any property attached to the results. How do I modify the query g.V('001').repeat(out('parent')).emit().dedup().toList() such that I will see node.name=b in the resultset?

# insert node 001 
g.V("001").hasLabel("mylabel").fold().coalesce(
                    unfold(),
                    addV("mylabel").property(T.id, "001").property("name", "a")
                ).iterate();

      
# insert node 002           
g.V("002").hasLabel("mylabel").fold().coalesce(
                    unfold(),
                    addV("mylabel").property(T.id, "002").property("name", "b")
                ).iterate();
     
# edge 001 ---(parent)---> 002              
g.V("001").hasLabel("mylabel").as("v").V("002").hasLabel("mylabel").coalesce(
    __.inE("created").where(outV().as("v")),
    addE("parent").from("v")).iterate()
    
    
# lookup parent from vertice 001 
g.V('001').repeat(out('parent')).emit().dedup().toList()
Kelvin Lawrence
  • 14,674
  • 2
  • 16
  • 38
user1187968
  • 7,154
  • 16
  • 81
  • 152

1 Answers1

0

In TinkerPop when you are using a remote database, such as Amazon Neptune, the only thing that is returned by default for a node/edge is a reference to the element. If you would like to return the property values for an element you need to specifically request them using the valueMap() or elementMap() which will return the K/V pairs for all the attributes on the element. In this case it would look like one of these options:

// A map of all the K/V attributes will be returned
g.V('001').repeat(out('parent')).emit().dedup().valueMap().toList()

//Same as above but will include the id and label as well
g.V('001').repeat(out('parent')).emit().dedup().valueMap().with(WithOptions.tokens).toList()

//Map of attributes/id/label as well as the in/out vertex information for an edge
g.V('001').repeat(out('parent')).emit().dedup().elementMap().toList()
bechbd
  • 6,206
  • 3
  • 28
  • 47