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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.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,我必须找到A和B之间具有附加属性的所有最短路径 此查询仅返回一条路由(如果是,则只有一条路由包含3个部分): 结果: {"start":{"identity":1,"labels":["town"],"properties":{"name":"Darjeeling"}},"end":{"identity":3,"labels":["peak"],"properties":{"altitude":"12400 ft","name":"Sandakphu"}},"segments":[{"start

我必须找到A和B之间具有附加属性的所有最短路径

此查询仅返回一条路由(如果是,则只有一条路由包含3个部分):

结果:

{"start":{"identity":1,"labels":["town"],"properties":{"name":"Darjeeling"}},"end":{"identity":3,"labels":["peak"],"properties":{"altitude":"12400 ft","name":"Sandakphu"}},"segments":[{"start":{"identity":1,"labels":["town"],"properties":{"name":"Darjeeling"}},"relationship":{"identity":2,"start":1,"end":0,"type":"trek","properties":{"distance":15,"name":"Darjeeling-Rimbik","winter":"true","summer":"true"}},"end":{"identity":0,"labels":["town"],"properties":{"name":"Rimbik"}}},{"start":{"identity":0,"labels":["town"],"properties":{"name":"Rimbik"}},"relationship":{"identity":3,"start":0,"end":2,"type":"trek","properties":{"distance":18,"name":"Rimbik-BhikeBhanja","winter":"true","summer":"true"}},"end":{"identity":2,"labels":["village"],"properties":{"name":"BhikeBhanja"}}},{"start":{"identity":2,"labels":["village"],"properties":{"name":"BhikeBhanja"}},"relationship":{"identity":4,"start":2,"end":3,"type":"trek","properties":{"distance":4,"name":"BhikeBhanja-Sandakphu","winter":"true","summer":"true"}},"end":{"identity":3,"labels":["peak"],"properties":{"altitude":"12400 ft","name":"Sandakphu"}}}],"length":3}
此路由的所有部分都将属性winter设置为true,但如果我想将此条件添加到查询中,则没有结果:

MATCH (darjeeling { name: 'Darjeeling' }),(sandakphu { name: 'Sandakphu' }), 
    paths = allShortestPaths((darjeeling)-[*]-(sandakphu))
WHERE ALL (p IN relationships(paths) WHERE p.winter = true)
RETURN paths

我的问题是,为什么第二个查询即使在a和B之间有一条路由,也不会返回任何结果,这是最短的路由,并且该路由上的所有路径的属性winter都设置为true?

我相信您需要对路径进行另一次
匹配,如下所示:

MATCH (darjeeling { name: 'Darjeeling' }), (sandakphu { name: 'Sandakphu' })
MATCH paths = allShortestPaths((darjeeling)-[*]-(sandakphu))
WHERE ALL (p IN relationships(paths) WHERE p.winter = true)
RETURN paths

将此形式化为答案

看起来您得到的是字符串属性而不是布尔属性。此条件应适用于您:

其中p.winter=“true”

如果要将这些属性更改为布尔属性,则需要匹配具有此属性的所有关系,并使用:


SET p.winter=(p.winter=“true”)

遗憾的是,您的查询没有返回任何结果。添加了第一个查询的结果,希望能对您有所帮助吗?
winter
是布尔属性还是字符串属性?如果您的条件是
其中p.winter=“true”
,您会得到结果吗?事实上,它是一个字符串属性!它与“”一起工作。。。
MATCH (darjeeling { name: 'Darjeeling' }), (sandakphu { name: 'Sandakphu' })
MATCH paths = allShortestPaths((darjeeling)-[*]-(sandakphu))
WHERE ALL (p IN relationships(paths) WHERE p.winter = true)
RETURN paths