Neo4j的暗號多我有以下的Neo4j的Cypher查詢:關鍵字
MATCH (parentD:Decision)-[:CONTAINS]->(childD:Decision)
WHERE id(parentD) = {parentDecisionId}
WITH childD, parentD
OPTIONAL MATCH (parentD)<-[:DEFINED_BY]-(c:Criterion)<-[:VOTED_ON]-(vg:VoteGroup)-[:VOTED_FOR]->(childD)
OPTIONAL MATCH (parentD)<-[:DEFINED_BY]-(ch:Characteristic)<-[:SET_ON]-(v:Value)-[:SET_FOR]->(childD)
WITH childD, {criterion: c, weight: vg.avgVotesWeight} AS weightedCriterion, {characteristic: ch, value: v.value} AS valuedCharacteristic
RETURN childD AS decision, collect(weightedCriterion) AS weightedCriteria, collect(valuedCharacteristic) AS valuedCharacteristics
正如我在SDN 4項目的結果我希望以檢索一個List<DecisionMatrix>
@QueryResult
public class DecisionMatrix {
private Decision decision;
private List<WeightedCriterion> weightedCriteria;
private List<ValuedCharacteristic> valuedCharacteristics;
}
@QueryResult
public class WeightedCriterion {
private Criterion criterion;
private Double weight;
}
@QueryResult
public class ValuedCharacteristic {
private Characteristic characteristic;
private Object value;
}
眼下這個查詢返回正確的標準列表,但是具有特徵空元素的錯誤列表。
例如,我沒有符合該查詢條件,但結果我可以看到下面的結構具有兩個記錄任何特徵:
RDBMS : [{criterion=Node[161], weight=4.333333333333333}, {criterion=Node[160], weight=2.1666666666666665}] : [{characteristic=null, value=null}, {characteristic=null, value=null}]
NoSQL : [{criterion=Node[160], weight=4.333333333333333}, {criterion=Node[161], weight=2.5}, {criterion=Node[162], weight=4.2}] : [{characteristic=null, value=null}, {characteristic=null, value=null}, {characteristic=null, value=null}]
結果對於RDBMS
正確的一套標準( 2標準)和NoSQL
(3標準),但是有一組錯誤的特徵。我希望這些記錄都有一個空列表(0個元素)的特徵(這些節點沒有相關的特徵),但在第一個記錄中,我有2個空特徵(與列表長度相同的標準)和3個第二條記錄的空白特徵。
我在做什麼錯誤,以及如何解決它?
非常感謝!這正是我需要的。我使用Neo4j 3.1 – alexanoid