limit results passed to WITH

9 views
Skip to first unread message

Yaron Naveh

unread,
Sep 29, 2012, 8:39:58 PM9/29/12
to ne...@googlegroups.com
Hi

Take a look at this query:

START n=node(1)
MATCH (n)-[:depends_on]->(x),  (n)-[:depends_on]->(y)         
WITH x as x, y as y
MATCH z = x-[depends_on*1..1]->y
RETURN z.name
LIMIT 10

(in simple words: the first part gathers all nodes that depend_on node #1, and the second part returns all links between all nodes from before to themselves)

The first part before the WITH returns a huge amount of results, and now all of them are being matched at z. I would like to have something like this:

WITH x as x, y as y LIMIT 100

such that only first 100 results are passed along to the heavy processing. Is it possible?

Currently my query is stack due to this.

Thanks,
Yaron

Peter Neubauer

unread,
Sep 30, 2012, 4:33:15 AM9/30/12
to ne...@googlegroups.com
Yaron,
this is a request that has been coming up frequently. Could you please
open a feature request issue on this? For the time being, the Java API
(especially the traverals, see
http://docs.neo4j.org/chunked/snapshot/tutorial-traversal-concepts.html,
can do this, since you can specify your own Expanders and Evaluators.
Is that an option?

Cheers,

/peter neubauer

G: neubauer.peter
S: peter.neubauer
P: +46 704 106975
L: http://www.linkedin.com/in/neubauer
T: @peterneubauer

Wanna learn something new? Come to http://graphconnect.com
> --
>
>

Yaron Naveh

unread,
Sep 30, 2012, 8:41:33 AM9/30/12
to ne...@googlegroups.com
Thanks Peter

I'm using cypher over http via the node.js driver, so this is not an option for me.

>
> --
>
>

--





--

I'm on Twitter (@YaronNaveh)


Yaron Naveh

unread,
Sep 30, 2012, 9:09:05 AM9/30/12
to ne...@googlegroups.com
Maybe I can statistically reduce the results?
something like:

WHERE ID(x)%4=0
WITH x as x...

Is there a modulo operation or something similar? Otherwise I can assign a value 1..4 by myself to nodes though it is much less flexible.


On Sunday, September 30, 2012 2:41:35 PM UTC+2, Yaron Naveh wrote:
Thanks Peter

I'm using cypher over http via the node.js driver, so this is not an option for me.

Michael Hunger

unread,
Sep 30, 2012, 11:03:30 AM9/30/12
to ne...@googlegroups.com
There is a modulo operation, with % as you said. 

see: http://console.neo4j.org/r/403q5x

And you can perhaps use collect and then "filter" on those.


--
 
 

Reply all
Reply to author
Forward
0 new messages