Neo4j-将节点属性存储从字符串转换为数字? [英] Neo4j - convert node attribute storage from string to number?

查看:923
本文介绍了Neo4j-将节点属性存储从字符串转换为数字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Neo4j数据库,该数据库最初是使用Rest :: Neo4p Perl模块从Perl脚本创建的.由于某些未知原因,即使所有节点上所述属性的值都是数字(通过该属性的Cypher regex搜索验证),节点上的一个属性也创建为字符串.

I have a Neo4j database that was initially created from a Perl script using the Rest::Neo4p Perl module. For some unknown reason, one of the attributes on the nodes was created as a string, even though the values for said attribute on all of the nodes are numeric (verified through a Cypher regex search of that attribute).

是否有一种简单的方法可以将属性的存储类型从字符串转换为数字,而无需重新创建数据库?也许可以使用文本属性中的值创建数字类型的新属性的Cypher查询?

Is there an easy way to convert the attribute's storage type from string to a number short of recreating the database? Perhaps a Cypher query that would create a new attribute of numeric type using the value from the textual attribute?

谢谢

克里斯

推荐答案

我不确定如何(以及是否)可以使用Cypher进行此操作,但是可以使用Gremlin来转换属性:

I am not sure how (and if) you can do that with Cypher, but you could convert the attributes using Gremlin:

g.V.sideEffect { it.my_property_name = Integer.parseInt(it.my_property_name) }.iterate()

您还可以使用Java扩展或仅以嵌入式模式加载数据库并使用Java遍历进行转换.

You can also use a Java extension or just load the DB in embedded mode and convert using Java traversals.

这篇关于Neo4j-将节点属性存储从字符串转换为数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆