0
votes

I am using cypher query for shortest path.

               MATCH path = allshortestPaths((a:Place { Name:'Name-1' })-[*]
               -(b:Place { Name:'Name-2' }))
               WHERE ANY(x IN nodes(path) WHERE x.Status = "true")
               RETURN path

Above query is filtering the paths after getting the list of shortest paths.

But My requirement is it should filter paths internally with ANY(x IN nodes(path) WHERE x.Status = "true") conditions, then among the filtered paths, it should find the shortestpath.

Is this possible?

1
what version of Neo4j do you use ?logisima
On Neo4j 3.0, ALL and NONE predicates are evaluated during shortest path traversal. But the ANY one is not evaluated See neo4j.com/docs/developer-manual/current/…logisima
Thanks Luanne.we are using 3.0.3 versionraj

1 Answers

1
votes

It doesn't matter whether you get all shortest paths first and then filter for a condition or the other way around. As posted in the comment, the condition is used for the shortest path query.

Your query might be slow because all paths have to be evaluated to find the shortest path matching your condition (see link from comment).

If your query runs and returns something you are all good.