python - Neo4j:为什么我不能在 python 中通过 find_one 找到特定节点?

标签 python neo4j

我刚开始在 python2.7 中使用 Neo4j。现在我尝试了一个关于 Neo4j 的简单测试,但我无法在数据库中找到特定的节点。节点存在,但返回结果为'None'。 这是我的代码:

from py2neo import Graph,Node,Relationship
test_graph = Graph(
    "http://localhost:7474", 
    username="neo4j", 
    password="******"
)
test_node_1 = Node(label = "Person",name = "test_node_1")
test_node_2 = Node(label = "Person",name = "test_node_2")
test_graph.create(test_node_1)
test_graph.create(test_node_2)

node_1_call_node_2 = Relationship(test_node_1,'CALL',test_node_2)
node_2_call_node_1 = Relationship(test_node_2,'CALL',test_node_1)
test_graph.create(node_1_call_node_2)
test_graph.create(node_2_call_node_1)

find_code_1 = test_graph.find_one(
  label="Person",
  property_key="name",
  property_value="test_node_1"
)
print (find_code_1)

最佳答案

问题是您的节点语法略有偏差。您正在设置一个名为 label 的属性,其值为 Person,您并不是在创建 Person 节点。

语法应该是这样的:

test_node_1 = Node("Person",name = "test_node_1")
test_node_2 = Node("Person",name = "test_node_2")

希望这对您有所帮助。

问候, 汤姆

关于python - Neo4j:为什么我不能在 python 中通过 find_one 找到特定节点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46334047/

相关文章:

python - 如何在GAE上处理大文件?

date - Neo4j - 日期转换

java - Spring Data Neo4j 未将类字段映射到节点属性

python - 是否有可能/如何获取在 python 上运行 pythran 生成的 c++ 代码

python - Unicode 与 Unicode 表示法

python - 为什么我的脚本会引发TypeError : 'int' object is not subscriptable

python - 如何在异步 Python 函数中指定返回类型?

database - Neo4j 查询中的 "started streaming"和 "completed"有什么区别?

database - Neo4j 死锁

lucene - 在 Neo4j Lucene 索引的单个属性中存储多个值