我们使用OrientDB,在使用Gremlin终端时,我们无法查询单个用户ID。
我们有这个
gremlin> g.V('@class','PERSON')[0..<5].map();
==>{id=50269488}
==>{id=55225663}
==>{id=6845786}
==>{id=55226938}
==>{id=55226723}
gremlin> g.V('@class','PERSON').has('id',50269488)[0..<5].map();
gremlin>
正如您所看到的,我尝试过滤第一个ID,但它并没有返回任何内容。我甚至按照建议here
尝试对50269488L
进行类型转换
任何提示尝试什么?
答案 0 :(得分:2)
我猜是因为属性 id 以某种方式保留。 一个例子:
gremlin> g.V.id
==>#15:0
==>#15:1
...
这将返回RecordId而不是属性 id 。
来自工作室,例如:
create class PERSON extends V
create Property PERSON.id2 long
create vertex PERSON set id2 = 12345
然后这应该有效:
gremlin> g.V('@class','PERSON').has('id2',12345L)[0..<5].map();
==>{id2=12345}
<强>更新强>
此问题的解决方法是使用 getProperty 方法进行过滤:
g.V('@class','PERSON').filter{it.getProperty("id")==12345}[0..<5].map();