繁体   English   中英

Neo4j Cypher模式理解和条件

[英]Neo4j Cypher pattern comprehension and conditions

在我的Cypher查询中,我具有以下模式理解:

[ (parentD)<-[:DEFINED_BY]-(ch1:Characteristic)<-[:SET_ON]-(v1:Value)-[:SET_FOR]->(childD) | 
  {characteristicId: id(ch1),  value: v1.value, valueType: ch1.valueType, visualMode: ch1.visualMode} ] AS valuedCharacteristics

我已将parentCharacteristic添加到我的SDN 4 Characteristic实体中:

@NodeEntity
public class Characteristic extends Votable {

    private final static String DEPENDS_ON = "DEPENDS_ON";

    @Relationship(type = DEPENDS_ON, direction = Relationship.OUTGOING)
    private Characteristic parentCharacteristic;

...

}

现在,我需要扩展我的模式理解并添加一个条件,以便返回与以前相同的Characteristic集,但那些具有parentCharacteristic != NULL人和模式理解还应该返回在{includeCharacteristicIds}集合中具有ID Characteristic , ll提供给该查询作为参数。

为了避免没有子Characteristic所有Characteristic ,我添加了以下条件:

WHERE NOT ((ch1)<-[:DEPENDS_ON]-())

因此,完整的模式理解现在看起来像:

[ (parentD)<-[:DEFINED_BY]-(ch1:Characteristic)<-[:SET_ON]-(v1:Value)-[:SET_FOR]->(childD) WHERE NOT ((ch1)<-[:DEPENDS_ON]-()) | 
  {characteristicId: id(ch1),  value: v1.value, valueType: ch1.valueType, visualMode: ch1.visualMode} ] AS valuedCharacteristics

但是除了此Characteristic列表之外,还如何返回在{includeCharacteristicIds}集合中具有ID Characteristic

请帮助扩展此查询。

您可以将两个条件与这样的OR语句组合在一起...

WHERE NOT ((ch1)<-[:DEPENDS_ON]-()) OR id(ch1) IN myIDs

模式理解中的WHERE就像MATCH条件的WHERE一样。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM