Reputation: 695
My cypher query is
start item= node:jobSearch ("title:Job*") WITH collect(item) as items limit 10 RETURN items as job union start item2= node:jobSearch ("title:Job*") WITH collect(item2) as item2s , count(item2) as paths match (job1:Job)-[relation]-(relationNode) where
(relationNode.name IN ['java','Dance','Programming'] OR relation.duration IN
['java','Dance','Programming']) AND NOT (job1 IN item2s) AND paths < 10 RETURN job1 as job limit 8
where I have used limit 8 in above query , I want to use 10 - paths . How can i use this ?
Upvotes: 3
Views: 153
Reputation: 18002
So it would seem that you should be able to do this with an expression in the limit clause, or perhaps by computing the right integer in your last WITH
statement, (e.g. WITH (10-paths) as resultCount (...) limit resultCount
) but I tested this and it won't work.
Just for kicks, I looked into the neo4j source code to see if I was missing something. In this source file you can see some of the rules for clauses and parsing of the cypher language itself.
The bad news is that the LIMIT
expression expects either an unsigned integer literal, or a parameter. So basically you can't do what you're asking to do, unless you compute (10-paths)
in a separate query, then put into this query a {resultCount}
parameter, and then give it that pre-computed value. That would probably be a lot of work for not much value.
On the upside, unless your results are really monstrously huge, it's probably easiest to just LIMIT 10
and include the integer paths
in your result set so that the code that consumes these results knows to ignore any more results than that.
Upvotes: 4