Page alternative for selectively fetching SDN4 for page content

Pagination is currently not supported in SDN4 (Ref: Paging and Sorting in Spring Data Neo4j 4 )

You can specify SKIP and LIMIT clauses to extract parts of the results, however, for our system we also need the values โ€‹โ€‹getTotalPages (), isFirst () and isLast () from the page returned when a user paging request is executed.

Is there an alternative way to get these values โ€‹โ€‹using SDN4 / OGM? Alternatively, are there any recommendations / links to the code that can be provided to us to implement this ourselves (possibly when building the Page object)

Thanks!

0
java spring neo4j spring-data-neo4j-4 pagination
source share
1 answer

As you have gathered, the Pagination object in OGM, which supports the Spring Page object, does not use the page counter or returns it. Spring The page object provides a method for returning the total number of pages, but this requires a basic implementation โ€” Mongo, JPA, Neo4j, etc. Spring Page object uses this value to determine the presence or absence of the "next" page. Our implementation "tricks" by telling Spring what it always does, until a request for a new page gets fewer results per page.

Unfortunately, there is no generalized way to return the number of pages that does not involve first finding all the results, and then counting them. Doing this for user queries that can potentially return many thousands of rows gives the obvious risk of running out of heap space on the server. (Note that the basic implementation in Neo4j using SKIP and LIMIT does not require preloading all the results into memory, so it does not encounter this problem).

+3
source share

All Articles