Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to paginate query results with cypher?

Tags:

Is it possible to have cypher query paginated. For instance, a list of products, but I don't want to display/retrieve/cache all the results as i can have a lot of results.

I'm looking for something similar to the offset / limit in SQL.

Is cypher skip + limit + orderby a good option ? http://docs.neo4j.org/chunked/stable/query-skip.html

like image 353
sunix Avatar asked May 02 '13 12:05

sunix


People also ask

Is used in Cypher query language to combine the results from multiple queries?

The UNION clause is used to combine the result of multiple queries.

WHAT IS WITH clause in Cypher?

The WITH clause allows query parts to be chained together, piping the results from one to be used as starting points or criteria in the next. It is important to note that WITH affects variables in scope. Any variables not included in the WITH clause are not carried over to the rest of the query.

What Cypher syntax do you use to create a subquery?

CALL {} (subquery)

Is Cypher declarative or procedural?

In the graph technology ecosystem, several query languages are considered declarative: Cypher, SPARQL and Gremlin (which also includes some imperative features, as mentioned above).


2 Answers

SKIP and LIMIT combined is indeed the way to go. Using ORDER BY inevitably makes cypher scan every node that is relevant to your query. Same thing for using a WHERE clause. Performance should not be that bad though.

like image 124
tstorms Avatar answered Oct 01 '22 08:10

tstorms


Its like normal sql, the syntax is as follow

match (user:USER_PROFILE)-[USAGE]->uUsage  where HAS(uUsage.impressionsPerHour) AND (uUsage.impressionsPerHour > 100)  ORDER BY user.hashID  SKIP 10  LIMIT 10;  

This syntax suit to last version (2.x)

like image 22
Nadav Finish Avatar answered Oct 01 '22 08:10

Nadav Finish