Reputation: 35
I have a little problem with displaying the results from neo4j. I'm using a server side jquery datatable, in which I need to define the iTotalDisplayRecords, which is the number of records that resulted after the filtering. My cypher query is like this:
UNWIND {json} as data
WITH data
WHERE (data.entry =~ {searchText} OR ....)
RETURN { entry: data.entry, name: data.name, .... }
ORDER BY {field} ASC SKIP {offset} LIMIT {number}
So, I need the number of records before the LIMIT is applied, but I can't manage to retrieve that number, anyone can help me with this?
Thank you in advance
Upvotes: 1
Views: 757
Reputation: 39915
Naive idea: you can add a WITH
doing count(*)
as aggregation and collecting data into a collection that gets UNWIND
ed later on:
UNWIND {json} as data
WITH data
WHERE (data.entry =~ {searchText} OR ....)
WITH count(*) as count, collect(data) as dataColl
UNWIND dataColl as d
RETURN { entry: d.entry, name: d.name, .... , count: count}
ORDER BY {field} ASC SKIP {offset} LIMIT {number}
Upvotes: 1