Depth of parametrizing relationship Neo4jphp

I am new to Neo4j. I have the following query in which I tried to parameterize a value depthfor a relationship and it shows an error. If I remove the parameterization of the value depth, it works fine.

 $query="MATCH (a:user{id:{usd}})-[:likes*1..{depth}]->(b:product{id:{pid}})
         return a";
 $result = new Everyman\Neo4j\Cypher\Query($client, $query,
           array('usd' => 1234,'depth' => 3,'pid'=>3456));

Please help, thanks in advance

+4
source share
1 answer

Your conclusion is correct, and this is not a neo4jphp related issue. Cypher does not allow you to parameterize relationship depth. If your depth should be dynamic, you need to build your query as follows:

 $depth=some_value;
 $query="MATCH (a:user{id:{usd}})-[:likes*1.." . $depth . "]->(b:product{id:{pid}})
         return a"

PHP, 100% . , .

+2

Source: https://habr.com/ru/post/1529944/


All Articles