我如何在 neo4j 中编写这个查询?
我对 neo4j 和图形数据库都很陌生。我正在制作一个应用程序原型,我不知道应该如何编写这些查询
我有这个域:
User 餐厅 审查 TypeOfFood
因此一家餐馆有一个或多个 TypeOfFood,用户留下有关餐馆的评论。用户有一些喜欢的食物,与餐厅销售的食物类型相匹配。用户之间也以典型的朋友关系相互关联。
我想写的一些查询:
给我所有我的朋友评价为 3 星或以上的餐厅,这些餐厅制作的食物是我喜欢的(不包括我已经评论过的那些餐厅)
向我推荐我可能认识的朋友(我想这应该是这样的“所有是我朋友的朋友但还不是的朋友我的,按某事排序)
I'm very new to neo4j and to graph database in general. I'm prototyping an app, and I don't know how should i write these queries
I've this domain:
User
Restaurant
Review
TypeOfFood
So a Restarurant have one or many TypeOfFood, the User leaves reviews about restaurants. The User have some preferred foods, matching the TypeOfFood a restaurant sell. Also Users are related to each other with the typically friend relationship.
Some of the queries I'm trying to write:
Give me all the restaurants that my friends have rated with 3 or more stars that make the kind of food I like (exclude those restaurants that I already reviewed)
Suggest me friends I may know (I guess this should be something like "all the friends that are friends of my friends but no yet mine, order by something)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 Neo4j 的 Cypher 查询语言,您可以像这样编写查询:
选择评分最高的 20 家餐厅,按星级和评论数量排序
朋友的朋友
您可以在 Neo4j Webadmin Console 在您的数据集上,也可以在 Neo4j-shell 中,远程通过通过 Spring Data 的 Cypher-Rest-Plugin图表。
还有一个讨论 cypher 中类似查询的截屏。
您还可以使用 Gremlin、Neo4j-Traversers 或通过
getRelationships
手动遍历,如果你愿意。Using Neo4j's Cypher query language you could write your queries like this:
Selecting the top-20 best rated restaurants, sorted by stars and number of reviews
Friends of a Friend
You can execute these cypher queries in the Neo4j Webadmin Console on your dataset, but also in the neo4j-shell, remotely via the Cypher-Rest-Plugin via Spring Data Graph.
There is also a screencast discussing similar queries in cypher.
You can also use Gremlin, Neo4j-Traversers or manual traversing via
getRelationships
if you'd like.