如何在gremlin中获取一个名为ID的属性 [英] How to get an attribute named ID in gremlin
问题描述
谢谢。
在内部,Neo4j将所有ID存储为 java.lang.Long
对象。这是 id
属性的特殊行为。所有其他属性都与其隐含的数据类型一起存储。这就是为什么具有('name','VerisignCzagExtension')
工作原因(,因为 name
属性被排除从 v5086
被类型转换为 java.lang.Long
,从而失去了真正的价值。这可以解释
id
属性是不可变的(不能改变)。如果您需要使用具有
Gremlin步骤使 has('id',5086L)
假设顶点 id
是 5086
>并以 java.lang.Long
值存储。一个额外的 L
用于显式 java.lang.Long
类型转换,Neo4j会假设 java.lang.Integer
如果不添加 L
并且您的Gremlin步骤会再次导致零结果。 最后,您可能想要使用其他命名标识,例如使用键 name
的属性。
希望这有助于。
I'm getting weird results while writing a gremlin query. I can happily use the has function for most of the attributes for my nodes, for example "().has('name', 'VerisignCzagExtension').property('id')" will return v5086. But when I attempt to use the has function with the attribute id it never returns true. for example "().has('id', 'v5086').property('id')" returns no results. Anyone have any idea why this is happening?
Thanks.
Internally, Neo4j stores all IDs as java.lang.Long
objects. This is a special behavior for id
property only. All other properties are stored with their implied data types. That's a reason why has('name', 'VerisignCzagExtension')
works (because name
property is excluded from this special behavior meant for id
). I'm assuming v5086
is being type casted to java.lang.Long
, thus losing it's real value. That could explain zero results after a has('id', 'v5086')
Gremlin step.
AFAIK, id
property is immutable (can't be changed). If you need to make id
look ups for vertices using a has
Gremlin step, it would look something like has('id', 5086L)
assuming that the vertex id
is 5086
and is being stored as a java.lang.Long
value. An extra L
is for explicit java.lang.Long
type-casting, Neo4j would assume java.lang.Integer
if you don't add that L
and your Gremlin step would result in zero results again.
Finally, you might want to call your named ID something else, like a property with key name
.
Hope this helps.
这篇关于如何在gremlin中获取一个名为ID的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!