Multiple limits in one query


(Tomswinkels) #1

Hi,

In this case i will limit one of the subquery.

When i run the query below, the result of the first query 'monitor' returns only one result and not five results.

I can do a slice on the collection, but i think that is not a hard limit in Neo, only for the return?

Is there some other option?

Query

WITH collect(distinct monitor) AS monitors
UNWIND(monitors) AS monitor
WITH monitor
SKIP 0 LIMIT 5
OPTIONAL MATCH (monitor)-[:FOLLOWS]->(capcode:TS_P2000Capcode)
WITH monitor, capcode
SKIP 0 LIMIT 1
WITH monitor, collect(capcode) AS capcodes
WITH {capcodes: capcodes, monitor: monitor} AS monitors
RETURN {monitors: monitors} AS result```

(Andrew Bowman) #2

LIMIT applies to the number of rows, not the number of results per row, so LIMIT 5 means only 5 rows will be taken at that point.

We have a knowledge base entry here you may want to review for more options.