【发布时间】:2017-02-27 17:11:54
【问题描述】:
我在 Neo4j 中有一个图表结构,用于具有以下关系的问卷:
(a:Category)-[:INITIAL_QUESTION]->(b:Question)-[c:Answer*]->(d:Question)
具体问题文本包含在(b|d).text 中,每个问题的可能答案包含在关系c.response 中
从最初的问题来看,有些路径比其他路径更长。我希望返回看起来像这样:
{"category": "example questionnaire category",
"initialQuestion" : {
"id": 1,
"text": "Example text here",
"possibleAns": {
"yes" : {
"id": 2,
"text": "Second question text here?",
"possibleAns": {
"ans1": {/*Question 4 containing all possible child question nodes nested
in possibleAns*/},
"ans2": {/*Question 5 containing all possible child question nodes nested
in possibleAns*/},
}
},
"no" :{
"id": 3,
"text": "Different question text here?",
"possibleAns": {
"ans1": {/*Question 6 containing all possible child question nodes nested
in possibleAns*/},
"ans2": {/*Question 7 containing all possible child question nodes nested
in possibleAns*/},
}
}
}
}
}
以便整个类别问卷包含在单个嵌套地图中。我看过其他一些示例,但无法调整这些查询以满足我的需求,尤其是考虑到调查问卷分支的可变深度。
是否有使这成为可能的 Cypher 查询?如果不是,从数据库中检索整个问卷的最佳方法是什么?
【问题讨论】: