How to return all vertex and edge types in a path

I have a path that has two hops and each hop is a different vertex type. This is the path:

  • User (vertex)

  • User2EvaluationEvent (edge)

  • EvaluationEvent (vertex)

  • EvaluationEvent2ConceptItem (edge)

  • ConceptItem (vertex)

I want to return all the “ConceptItems” for a “User” and everything in-between.

This query returns only “ConceptItem” vertexes as expected:
image
image

And when I also PRINT the ListAccum of Event2Item edges I get this result.
image
image
Interesting…. it pulled in the green “EvaluationEvent” vertexes even though I didn’t explicitly request them.

Now I want to pull in the User vertex and the edges connecting the User to the “User2EvaluationEvent” edges. I’m guessing I need to pull in another ListAccum of “User2EvaluationEvent” edges. Right?

OK, here is my query which has an error.
image

And the error is:
“Error: mismatched input ‘accum’ expecting {HAVING, INTERSECT, LIMIT, MINUS, ORDER, POST_ACCUM, UNION, ‘%’, ‘&’, ‘+’, ‘-’, ‘*’, ‘/’, ‘.’, ‘,’, ‘;’, ‘>’, ‘|’, ‘<<’}”

What do I need to do to return everything between “User” and all “ConceptItem” vertexes and everything in-between? Below is the text for the query.

CREATE QUERY GetUserEventsItems(vertex<User> inputUser) FOR GRAPH MyGraph syntax v2 { 
	ListAccum<edge>@@edgeEvent2Items;
	ListAccum<edge>@@edgeListUserEvents;	
	
	Start = {inputUser};
	
	Items = SELECT tItm FROM Start:s-(User2EvaluationEvent>:eUserEvent)-EvaluationEvent:tEvent-(EvaluationEvent2ConceptItem>:eEvItm)-ConceptItem:tItm
	
	ACCUM @@edgeEvent2Items += eEvItm
	ACCUM @@edgeListUserEvents += eUserEvent;
	
	Print inputUser;
	Print Items;
	Print @@edgeEvent2Items;		
}

Thank you.

So there is good news and possibly bad news :).

The good news is, if you want to do two things in ACCUM, then you separate the clauses with a comma (don’t repeat the ACCUM keyword), something like (not tested):

ACCUM @@edgeEvent2Items += eEvItm,
@@edgeListUserEvents += eUserEvent;

The [possibly] bad news is that V2 syntax is limited in what it can extract from an extended path. This depends on which version you are using. So, if the comma thing doesn’t work then you may need to break up your query into two select statements. Again not tested but should look like:

Start = {inputUser};

tEvents = SELECT tEvent FROM Start:s-(User2EvaluationEvent>:eUserEvent)-EvaluationEvent:tEvent
    ACCUM @@edgeEvent2Items += eEvItm;

Items = SELECT tItm from tEvents:s -(EvaluationEvent2ConceptItem>:eEvItm)-ConceptItem:tItm
    ACCUM @@edgeListUserEvents += eUserEvent;

Thank you Richard, You are correct about the V2 syntax not supporting this. However the 2nd option worked fine and I don’t see any downside of this for now.

FYI, To all who answer my questions, these are a HUGE help in my learning and moving the ball down the field - time well spent. Thanks Again!