python - py2neo 是否通过 REST API 访问 Neo4j 中的所有数据类型字符串?

标签 python nosql neo4j cypher py2neo

我有一个在 neo4j 中创建新节点的表单查询:

cypher.get_or_create_indexed_node(index="person", key="name", value="Fred", properties={"level": 1}

但是,当我查询 Fred 以检查他的属性时,他的级别 =“1”/带引号/。似乎有东西正在将他的值转换为字符串。这无关紧要——如有必要,我可以在检索时转换它——除非我尝试进行密码查询,例如...

start b = node:person("*:*") RETURN b.level, ID(b) ORDER BY b.level desc SKIP 5 LIMIT 5;

...我注意到 b.level 没有按预期排序。我看到类似的东西:

==> +-------------------------+
==> | b.level         | ID(b) |
==> +-------------------------+
==> | "3"             | 42    |
==> | "0"             | 53    |
==> | "2"             | 57    |
==> | "0"             | 63    |
==> | "2"             | 20    |
==> +-------------------------+

当我期待这样的事情时:

==> +-------------------------+
==> | b.level         | ID(b) |
==> +-------------------------+
==> | 3               | 42    |
==> | 2               | 20    |
==> | 2               | 57    |
==> | 0               | 63    |
==> | 0               | 53    |
==> +-------------------------+

我假设这是一个数据类型问题,因为 reference manual显示跳过/限制功能。

是否所有值都是字符串,或者我应该正确添加其他内容?

最佳答案

这不应该是这样的,数字属性是完全支持的。我也无法使用以下测试重新创建场景:

def test_get_or_create_indexed_node_with_int_property(self):
    graph_db = neo4j.GraphDatabaseService()
    fred = graph_db.get_or_create_indexed_node(index="person", key="name", value="Fred", properties={"level" : 1})
    assert isinstance(fred, neo4j.Node)
    assert fred["level"] == 1
    graph_db.delete(fred)

我注意到您在 get_or_create_indexed_node 方法前加上了 cypher - 我不希望这样,因为 cypher 模块没有这样的方法。相反,我希望它是 graph_dbbatch 之类的东西。也许这是一个错字?

也许您可以分享更多您的相关代码?它周围的其他因素可能会影响您的结果。

尼格

关于python - py2neo 是否通过 REST API 访问 Neo4j 中的所有数据类型字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13832099/

相关文章:

java - spring data neo4j 和 spring 版本,冲突

scala - 在 Scala 中使用 Neo4j

python - scipy.integrate.ode.integrate() 是如何工作的?

python - 从 python 在文件中添加段落

MongoDB 查找文档的所有属性

java - 谷歌应用引擎: Data Options

mongodb - 在 Mongoose 中进行小时/日/月/年的范围查询

python - 下标序列时Python中的::(双冒号)是什么?

python - Cygwin 上的 MySQLdb

java - 运行查询时 Neo4j NullPointerException