We are trying to convert the Neo4j chypre query into a Gremlin query, but we are stuck on some extract methods in the chypre query that need to be converted into the Gremlin query. The chypre query follows:
MATCH (from: `Person` {title: "John"}), (to: `Location` {title: "New York City"})MATCH p = (from)-[rel*..5]->(to)RETURN extract(x IN nodes(p) | x.title) as title,extract(i IN relationships(p)| type(i)) as relation,extract(j IN nodes(p) | j.nt) as node,length(p) as len,extract(x IN nodes(p) | x) as node_data,extract (i in nodes(p)| id(i)) as id,extract(i IN relationships(p)| id(i)) as rel_id,extract(rel IN relationships(p) | id(startNode(rel))) as start,extract(rel IN relationships(p) | id(endNode(rel))) as end
MATCH (from: `Person` {title: "John"}), (to: `Location` {title: "New York City"})MATCH p = (from)-[rel*..5]->(to)RETURN extract(x IN nodes(p) | x.title) as title,extract(i IN relationships(p)| type(i)) as relation,extract(j IN nodes(p) | j.nt) as node,length(p) as len,extract(x IN nodes(p) | x) as node_data,extract (i in nodes(p)| id(i)) as id,extract(i IN relationships(p)| id(i)) as rel_id,extract(rel IN relationships(p) | id(startNode(rel))) as start,extract(rel IN relationships(p) | id(endNode(rel))) as end
Output of the above query as follow:
[ { "title": ["John", "new york city"], // 'title' is property of the vertices "relation": ["WORKIGN_AT"], // Edge label between nodes "node": ["Person", "Location"], // List of labels "len": 1, // Node hop between two node label "node_data": [ // List of node property data { "Employee_Status": "Active", "FT_or_PT": "Full Time", "title": "john" }, { "Office_Type": "Headquarters", "Mailing_Code": 10022, "ISO_Alpha_Two_Country_Code": "US", "City": "New York", "title": "New York City", "Display": "New York City", "Name": "New York City" } ], "id": [5432,5125], // List of node id in the hopes "rel_id": [17409], // list of edge id in the hopes "start": [5432], // id of from nodes in the hopes "end": [5125] // id of to nodes in the l }]
[ { "title": ["John", "new york city"], // 'title' is property of the vertices "relation": ["WORKIGN_AT"], // Edge label between nodes "node": ["Person", "Location"], // List of labels "len": 1, // Node hop between two node label "node_data": [ // List of node property data { "Employee_Status": "Active", "FT_or_PT": "Full Time", "title": "john" }, { "Office_Type": "Headquarters", "Mailing_Code": 10022, "ISO_Alpha_Two_Country_Code": "US", "City": "New York", "title": "New York City", "Display": "New York City", "Name": "New York City" } ], "id": [5432,5125], // List of node id in the hopes "rel_id": [17409], // list of edge id in the hopes "start": [5432], // id of from nodes in the hopes "end": [5125] // id of to nodes in the l }]
I'm looking for a Gremlin query that can effectively replace the extract method for Neo4j and produce the same output. Your insights would be greatly appreciated.
Similar Threads
Recent Announcements
Continue the conversation
Join the Discord to ask follow-up questions and connect with the community
AT
Apache TinkerPop
Apache TinkerPop is an open source graph computing framework and the home of the Gremlin graph query language.