Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Neo4j密码查询:使用ORDER BY和COLLET_Neo4j_Cypher_Collect - Fatal编程技术网

Neo4j密码查询:使用ORDER BY和COLLET

Neo4j密码查询:使用ORDER BY和COLLET,neo4j,cypher,collect,Neo4j,Cypher,Collect,我很难从两个不同的来源收集数据并合并这些集合,这样最后一个集合就是一组按“dateCreated”排序的对象 上下文 用户可以分组提问。 问题可以是一般性的,也可以是与特定视频游戏相关的。 如果小组中提出的问题与视频游戏相关,此问题也会出现在视频游戏的“问题”页面中 目前,我有两个一般性问题和一个特定于一个视频游戏的问题。 因此,在获取问题时,我应该有3个问题 查询 问题是: START group = node(627) MATCH generalQuestions-[?:GENERAL_QU

我很难从两个不同的来源收集数据并合并这些集合,这样最后一个集合就是一组按“dateCreated”排序的对象

上下文

用户可以分组提问。 问题可以是一般性的,也可以是与特定视频游戏相关的。 如果小组中提出的问题与视频游戏相关,此问题也会出现在视频游戏的“问题”页面中

目前,我有两个一般性问题和一个特定于一个视频游戏的问题。 因此,在获取问题时,我应该有3个问题

查询

问题是:

START group = node(627)
MATCH generalQuestions-[?:GENERAL_QUESTION]->group
WITH group, generalQuestions
MATCH gamesQuestions-[?:GAME_QUESTION]->games<-[:GAMES]-group
WITH (collect(generalQuestions) + collect(gamesQuestions)) as questions
RETURN questions
ORDER BY questions.dateCreated
实现我所要做的事情的正确方法是什么

第二期:错误结果

如果我删除ORDERBY子句,而不是得到3个结果,我得到14…:

[
Node[641]{dateCreated:1380892636,dateUpdated:1380892636,title:"GENERAL TITLE 1",type:1,content:"GENERAL CONTENT 1"},
Node[641]{dateCreated:1380892636,dateUpdated:1380892636,title:"GENERAL TITLE 1",type:1,content:"GENERAL CONTENT 1"},
Node[641]{dateCreated:1380892636,dateUpdated:1380892636,title:"GENERAL TITLE 1",type:1,content:"GENERAL CONTENT 1"},
Node[641]{dateCreated:1380892636,dateUpdated:1380892636,title:"GENERAL TITLE 1",type:1,content:"GENERAL CONTENT 1"},
Node[641]{dateCreated:1380892636,dateUpdated:1380892636,title:"GENERAL TITLE 1",type:1,content:"GENERAL CONTENT 1"},
Node[641]{dateCreated:1380892636,dateUpdated:1380892636,title:"GENERAL TITLE 1",type:1,content:"GENERAL CONTENT 1"},
Node[642]{dateCreated:1380892642,dateUpdated:1380892642,title:"GENERAL TITLE 2",type:1,content:"GENERAL CONTENT 2"},
Node[642]{dateCreated:1380892642,dateUpdated:1380892642,title:"GENERAL TITLE 2",type:1,content:"GENERAL CONTENT 2"},
Node[642]{dateCreated:1380892642,dateUpdated:1380892642,title:"GENERAL TITLE 2",type:1,content:"GENERAL CONTENT 2"},
Node[642]{dateCreated:1380892642,dateUpdated:1380892642,title:"GENERAL TITLE 2",type:1,content:"GENERAL CONTENT 2"},
Node[642]{dateCreated:1380892642,dateUpdated:1380892642,title:"GENERAL TITLE 2",type:1,content:"GENERAL CONTENT 2"},
Node[642]{dateCreated:1380892642,dateUpdated:1380892642,title:"GENERAL TITLE 2",type:1,content:"GENERAL CONTENT 2"},
Node[632]{dateCreated:1380889484,dateUpdated:1380889484,title:"GTA5 TITLE",type:2,content:"GTA5 CONTENT"},
Node[632]{dateCreated:1380889484,dateUpdated:1380889484,title:"GTA5 TITLE",type:2,content:"GTA5 CONTENT"}
]
我收集结果的方式有问题吗

编辑

展开查询以获取gamesQuestion:

gamesQuestions-[:GAME_QUESTION]->()<-[:QUESTIONS]-games-[:INTERESTS]->()<-[:HAS_‌​INTEREST_FOR]-interests<-[:INTERESTS]-group
gamesQuestions-[:GAME\u QUESTION]->()()该“Order by”要求节点或关系上有一个属性。查询中的“问题”是节点的集合,而不是节点/关系,不能使用“排序依据”对集合进行排序,只能根据其属性对节点或关系进行排序

为了使用“order by”,您需要将问题作为行的列而不是集合返回。根据原始查询中指示的关系,以下查询应将常规和特定游戏问题作为一列行返回,并根据属性“dateCreated”对其进行排序

这样做的目的是将能够到达组节点的问题与一个步骤或四个以上步骤相匹配

另一个选项是在where子句中指定这两种模式

START group = node(627) 
MATCH question-[*]-group
Where question-[:GENERAL_QUESTION]->group or (question-[:GAME_QUESTION]->()<-[:QUESTIONS]-()-[:INTERESTS]->()<-[:HAS_INTERESTS_FOR]-()<-[:INTERESTS]-group)
Return distinct q
Order by q.dateCreated
开始组=节点(627)
匹配问题-[*]-组

问题-[:一般问题]->小组或(问题-[:游戏问题]->()()丽莎,谢谢你的回答!我理解为什么我不能使用Order By。但是让我们说“游戏问题”,而不是游戏提问-[?:游戏问题]->游戏()()非常感谢丽莎!:)
START group = node(627) 
Match question-[?:GENERAL_QUESTION|GAME_QUESTION]->()<-[:GAMES*0..1]-(group)
Return distinct question
Order by question.dateCreated
START group = node(627) 
Match question-[:GENERAL_QUESTION|GAME_QUESTION]->()-[*0..4]-(group)
Return distinct question
Order by question.dateCreated
START group = node(627) 
MATCH question-[*]-group
Where question-[:GENERAL_QUESTION]->group or (question-[:GAME_QUESTION]->()<-[:QUESTIONS]-()-[:INTERESTS]->()<-[:HAS_INTERESTS_FOR]-()<-[:INTERESTS]-group)
Return distinct q
Order by q.dateCreated