cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Finish UNWIND list before executing new/next lines

Hello everyone!

This is another syntex doubt (that I couldn't find an answer elsewhere), now about UNWIND.
As per my previous research I can't use FOREACH if I want to use MATCH after that. In this case UNWIND is recommended. Right?
Below is a representative example. I even might be able to rewrite it to have a single UNWIND...

BUT the main point is.... HOW COULD I force to go to next "item" in the "list" before executing new/next command line?

.

01.	# Preparing and starting first UNWIND 
02.	WITH [101,102,103,104] as topusers
03.	UNWIND topusers as topuser 
04.		MATCH ....
05.		....
06.		# Preparing and starting second UNWIND
07.		WITH topuser, .... as friends, [1,2,3,4,5,6] as list
08.		UNWIND list as item
09.			MATCH ....
10.			....
11.			CASE .... value = value +1
12.			ELSE .... value
13.			END value
14.			# Jump back to second UNWIND (line 08) to finish the list.... HOW TO DO IT????
15.	# For each "topuser", print "friends" and its final "value"
16.	RETURN topuser, friends, value

.
The Neo4j version I'm using is 3.5.14.

Again, I really appreciate your help!!!

1 REPLY 1

One approach would be to filter the list to only contain those wanted for the unwind:

unwind [x in list where <predicate>] as x ...