Question

Having these VERTEX maps

 **a**) ( County, StreetName, GroupName, Type, BaseRecId, Latitude,
          StreetSuffix, Longitude, StreetNumber, Zip, City )
 **b**) ( SalesPrice, SalesRecId, BaseRecId, SalesDate )

I need to create EDGES ( 1 to many ), from VERTEX a to VERTEX b when the PROPERTY BaseRecId MATCHES.

Was it helpful?

Solution

First select all vertices of Group a, then the matching vertices of Group b and finally link them together:

g.V().hasNot("BaseRecId", null).hasNot("GroupName", null).as("a").transform({
  g.V("BaseRecId", it.getProperty("BaseRecId")).hasNot("SalesRecId", null)
}).scatter().linkIn("label", "a")

Assumptions in this query:

  • each vertex in Group a has a GroupName
  • each vertex in Group b has a SalesRecId
  • BaseRecId is indexed (this is optional, but would speed things dramatically up)

This should work for a small graph. For larger graphs use Faunus.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top