简体   繁体   English

Neo4j的密码查询中迭代的节点

[英]nodes iterating in cypher query of Neo4j

in this case iam having house No's as nodes and i want to iterate them and pass them as parameter for creating relationship between people and house No's here is the code.. 在这种情况下,iam将房屋编号作为节点,我想对其进行迭代,并将它们作为创建人与房屋编号之间的关系的参数进行传递,这是代码。

START n=node(*)
WHERE 
  HAS(n.house_no) 
RETURN n;

from the above i will get house no's nodes and then i want to pass them into another query 从上面我会得到房子的节点,然后我想将它们传递给另一个查询

START 
    n=node:node_auto_index(house_no="4-10"),
    n2=node:node_auto_index(houseNo="4-10") 
WHERE 
    HAS(n.house_no) AND HAS(n2.houseNo) AND n.house_no = n2.houseNo
    create UNIQUE
    (n2)-[:LIVESIN]->(n)
    return n2.name

in the above query i want to pass house no's nodes property ex:house_no 在上面的查询中,我想传递房屋号的节点属性ex:house_no

How come i iterate nodes and pass a property in it as parameter.. is there any chance to combine both these queries? 我如何迭代节点并在其中传递属性作为参数。是否有机会组合这两个查询?

can any one help me? 谁能帮我?

To combine your queries you can use WITH . 要合并查询,可以使用WITH From the documentation : 文档中

In Cypher, the WITH clause is used to pipe the result from one query to the next.` 在Cypher中, WITH子句用于将结果从一个查询传递到下一个查询。

I've never tried doing index lookups based on 'piped results', would this work: 我从来没有尝试过基于“管道结果”进行索引查找,这会起作用:

START n=node(*)
WHERE HAS(n.house_no)
WITH n.house_no as house_no
START n2=node:node_auto_index(houseNo=house_no)
CREATE UNIQUE n2-[:LIVESIN]->n
RETURN n2.name

You can pass parameters for the index-lookup in the start clause like this: 您可以在start子句中为index-lookup传递参数,如下所示:

START 
    n =node:node_auto_index(house_no={house_no}),
    n2=node:node_auto_index(houseNo={house_no}) 
WHERE 
    HAS(n.house_no) AND HAS(n2.house_no) AND n.house_no = n2.houseNo
CREATE UNIQUE
    (n2)-[:LIVESIN]->(n)
RETURN n2.name

and then pass a map like


{house_no:"4-10"}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM