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.

WITH * causes Cypher query to short circuit

alex3
Node Clone

I have a (relatively) nontrivial cypher query, but I have reduced it down to a small example that still breaks:

CALL db.index.fulltext.queryNodes("MyIndexName", "'My Search Phrase'~0.8")
YIELD node
WITH *, collect(node) as nodes
RETURN nodes

The problem is that when nodes is an empty list (the index search returned no results) the rest of my query does not execute when I include a with *. If I omit the with *, then the query would correctly return the empty list nodes = [].

Any ideas as to why this might be happening?

1 REPLY 1

@alex3

This is a normal behavior, because WITH * in your case is equivalent to WITH node,
and if node return nothing, so everything else returns nothing, because WITH clause works like RETURN, therefore your query is equivalent to:

CALL db.index.fulltext.queryNodes("MyIndexName", "'My Search Phrase'~0.8") yield node 
return node, collect(node) as nodes