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 密码自定义路径输出_Neo4j_Cypher - Fatal编程技术网

Neo4j 密码自定义路径输出

Neo4j 密码自定义路径输出,neo4j,cypher,Neo4j,Cypher,我在Cypher中有以下查询 MATCH(n:Resource{uri:'http://elite.polito.it/ontologies/dogont.owl#StateValue'},(m:Resource{uri:'http://elite.polito.it/ontologies/dogont.owl#Actuator'}),p=allshortestpath((n)-(r*]-(m)),其中无(x在节点(p)中,其中x.uri=)http://www.w3.org/2002/07/o

我在Cypher中有以下查询

MATCH(n:Resource{uri:'http://elite.polito.it/ontologies/dogont.owl#StateValue'},(m:Resource{uri:'http://elite.polito.it/ontologies/dogont.owl#Actuator'}),p=allshortestpath((n)-(r*]-(m)),其中无(x在节点(p)中,其中x.uri=)http://www.w3.org/2002/07/owl#Thing') 
返回p

它将返回以下结果:

│[{"uri":"http://elite.polito.it/ontologies/dogont.owl#StateValue"},{},│
│{"uri":"http://elite.polito.it/ontologies/dogont.owl#realStateValue"},│
│{"uri":"http://elite.polito.it/ontologies/dogont.owl#realStateValue"},│
│{},{"uri":"http://www.w3.org/2001/XMLSchema#string"},{"uri":"http://ww│
│w.w3.org/2001/XMLSchema#string"},{},{"uri":"http://purl.org/goodrelati│
│ons/v1#serialNumber"},{"uri":"http://purl.org/goodrelations/v1#serialN│
│umber"},{},{"rdfs__comment":"All building things that can be controlle│
│d by domotic system","uri":"http://elite.polito.it/ontologies/dogont.o│
│wl#Controllable","rdfs__label":"Controllable"},{"rdfs__comment":"All b│
│uilding things that can be controlled by domotic system","uri":"http:/│
│/elite.polito.it/ontologies/dogont.owl#Controllable","rdfs__label":"Co│
│ntrollable"},{},{"rdfs__comment":"A mechanism that puts something into│
│ automatic action","uri":"http://elite.polito.it/ontologies/dogont.owl│
│#Actuator","rdfs__label":"Actuator"}]                                 │

结果,中间节点出现两次。为什么会发生这种情况以及如何防止这种情况?同样就目前而言,
关系
是空白的,如何将
关系
{}
替换为其
类型
返回的路径由一系列关系组成,每个关系返回的数据实际上是一个三元组(开始节点、关系、结束节点)。因此,一个关系的结束节点再次显示为下一个关系的开始节点

如果只想获得没有节点的关系,可以使用
relationships(p)
;如果您只想要没有关系的节点,可以使用
nodes(p)

如果您想生成自己的路径列表,而不需要折叠节点,请尝试以下操作:

MATCH
  (n:Resource { uri: 'http://elite.polito.it/ontologies/dogont.owl#StateValue'}),
  (m:Resource { uri: 'http://elite.polito.it/ontologies/dogont.owl#Actuator'}), 
  p=allShortestPaths((n)-[*]-(m))
WHERE NONE(x IN NODES(p) WHERE x.uri='http://www.w3.org/2002/07/owl#Thing') 
RETURN REDUCE(s=[PROPERTIES(n)], r IN RELATIONSHIPS(p) | s + r + ENDNODE(r)) AS p

在将
s+r+ENDNODE(r)
更改为
s+{type:type(r)}+ENDNODE(r)
的结果中,是否可能获得r本身的类型。