Pentium10
Pentium10

Reputation: 207830

Gremlin access a property "id"

We use OrientDB and when using the Gremlin terminal, we cannot query for a single user id.

We have this

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>

As you can see I tried filtering for that first id, but it doesn't return anything. I even tried typecasting to 50269488L as suggested here

any tips what to try?

Upvotes: 0

Views: 488

Answers (1)

vitorenesduarte
vitorenesduarte

Reputation: 1579

I guess it's because property id is reserved somehow. An example:

gremlin> g.V.id
==>#15:0
==>#15:1
...

This returns the RecordId instead of the property id.


From studio, e.g.:

create class PERSON extends V
create Property PERSON.id2 long
create vertex PERSON set id2 = 12345

Then this should work:

gremlin> g.V('@class','PERSON').has('id2',12345L)[0..<5].map();
==>{id2=12345}

UPDATE:

A workaround to this problem is to filter with getProperty method:

g.V('@class','PERSON').filter{it.getProperty("id")==12345}[0..<5].map();

Upvotes: 2

Related Questions