Paging with Spring Data Graph/Neo4j

[亡魂溺海] 提交于 2019-12-23 19:12:00

问题


Is it possible to fetch Page results when using Spring Data Graph (Neo4J) as the data store?

The findAll(Pageable) seems to be the only Pageable query availalble when using the GraphRepository. What I am looking for is Pageable APIs for other findBy***() like queries.

Perhaps, there may be a completely different (recommended) way to Page results using Spring Data Graph. Thoughts on that are welcome as well!


回答1:


Spring Data Neo4j (2.0 currently in SNAPSHOT but soon RC1) added Page support for the derived and annotated queries. The findAll() is inherited from CRUD-Repository.

We could add Page support for the default query methods. Could you raise a JIRA issue for that?

Example for derived and @Query annotated Page methods.

interface UserRepository extends GraphRepository<User> {
   // derived method
   Page<User> findByTag(String tag, Pageable page);
   @Query("start user=node({0}) match user-[r:RATED]-product where r.stars > 3 return product order by r.stars desc")
   Page<Product> getRatedProducts(User user);
}

Just add cypher (or gremlin) as dependency to your application:

<dependency>
   <groupId>org.neo4j</groupId>
   <artifactId>neo4j-cypher</artifactId>
   <version>${neo4j.version}</version>
</dependency>


来源:https://stackoverflow.com/questions/8028701/paging-with-spring-data-graph-neo4j

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!