按关系顺序排序属性neo4j [英] Order by relationship properties neo4j

查看:419
本文介绍了按关系顺序排序属性neo4j的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Neo4j 1.9.3-

Using Neo4j 1.9.3 -

我想创建一个音乐节目列表.在给定的程序上,可能要执行三个操作.每件作品都有一个与之相关的作曲家,并且可能会出现在许多不同的程序中,因此我无法在作品节点上放置序列号.

I want to create a music program listing. On a given program there may be three pieces being performed. Each piece has a composer associated with them, and may appear on many different programs, so I can't put sequence numbers on the piece nodes.

我认为我可以创建程序,并与每个部分建立关系,就像这样:

I assume I can create the program, with relationships to each piece like so:

(program1)-[:PROGRAM_PIECE {program_seq: 1}]->(piece1)
(program1)-[:PROGRAM_PIECE {program_seq: 2}]->(piece2)
(program1)-[:PROGRAM_PIECE {program_seq: 3}]->(piece3)

我的问题是,如何查询图形,以便按关系属性program_seq的顺序排列?我可以将ORDER BY与节点属性一起使用,但是在关系方面(我的人生故事...)并没有成功

My question is, how do I query the graph so that the pieces are in order of the relationship property program_seq? I'm fine using ORDER BY with node properties, but have not been successful with relationships (story of my life...)

推荐答案

如果喜欢,请将其锁定:即,将其绑定到变量.然后,可以像处理节点属性一样使用ORDER BY.如果您以(program1)的身份检索程序,则可以执行类似

If you like it, lock it down: that is, bind it to a variable. Then you can use ORDER BY the same way you would with node properties. If you have retrieved your program as (program1) you can do something like

MATCH (program1)-[r:PROGRAM_PIECE]->(piece1)
  RETURN program1, r, piece1
  ORDER BY r.program_seq

这篇关于按关系顺序排序属性neo4j的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆