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 Cypher:是否可以在Cypher查询中动态传递节点的重新指定字段?_Neo4j_Cypher_Spring Data Neo4j - Fatal编程技术网

Neo4j Cypher:是否可以在Cypher查询中动态传递节点的重新指定字段?

Neo4j Cypher:是否可以在Cypher查询中动态传递节点的重新指定字段?,neo4j,cypher,spring-data-neo4j,Neo4j,Cypher,Spring Data Neo4j,我试图找到动态传递返回参数的方法,这样我就可以在多种情况下重用查询,比如在一种情况下我需要两个节点字段,在另一种情况下我需要三个字段,比如 所以这里我需要两个属性id和user的name Match (n:User) where id(n)={0} return n = {1}; //cypher params to pass= {0=1,1={id(n) as id,n.name as name}}; 这里,我需要user的三个属性 Match (n:User) where id(n)=

我试图找到动态传递返回参数的方法,这样我就可以在多种情况下重用查询,比如在一种情况下我需要两个节点字段,在另一种情况下我需要三个字段,比如

所以这里我需要两个属性id和user的name

Match (n:User) where id(n)={0} return n = {1};   //cypher params to pass= {0=1,1={id(n) as id,n.name as name}};
这里,我需要user的三个属性

Match (n:User) where id(n)={0} return n = {1};   //cypher params to pass= {0=1,1={id(n) as id,n.name as name,n.active as active}};
所以可以动态地传递返回参数


谢谢,如果您有任何帮助,我们将不胜感激。

据我所知,您希望根据传递给查询的参数,在查询结束时返回一组不同的值吗?你可以很容易地在cypher中实现这一点,使用类似下面的东西

例如,夹具:

CREATE (u:ExampleUser { name: "Test User" })
查询:

WITH 0 AS return_type  // change to 1 to see just name!
MATCH (u:ExampleUser) WHERE u.name = "Test User"
WITH 
  CASE return_type
    WHEN 0 THEN { name: u.name, id: id(u) }
    WHEN 1 THEN { name: u.name }
  END AS return_value
RETURN return_value
这里我们使用
CASE
操作符将
return\u type
的值设置为两个映射之一,具体取决于
return\u type
的值。您可以将示例中的
0
替换为
1
,以仅获取名称。同样,替换为参数以动态更改输出。您还可以根据需要添加更多的
WHEN x THEN y
子句


您的输出将是一个名为
return\u value

的映射,据我所知,您希望在查询结束时返回一组不同的值,具体取决于传递给查询的参数?你可以很容易地在cypher中实现这一点,使用类似下面的东西

例如,夹具:

CREATE (u:ExampleUser { name: "Test User" })
查询:

WITH 0 AS return_type  // change to 1 to see just name!
MATCH (u:ExampleUser) WHERE u.name = "Test User"
WITH 
  CASE return_type
    WHEN 0 THEN { name: u.name, id: id(u) }
    WHEN 1 THEN { name: u.name }
  END AS return_value
RETURN return_value
这里我们使用
CASE
操作符将
return\u type
的值设置为两个映射之一,具体取决于
return\u type
的值。您可以将示例中的
0
替换为
1
,以仅获取名称。同样,替换为参数以动态更改输出。您还可以根据需要添加更多的
WHEN x THEN y
子句

您的输出将是一个名为
return\u value
的映射