orientdb-gremlin
orientdb-gremlin copied to clipboard
Get vertex by class
Hi, is it possible to make a query that gives back all vertices of specified class?
There is a graph.getVerticesOfClass("xxx")
method availible in current orientd graph api but not in this backend.
Also I have found following snippets:
graph.V.has("@class","xxx")
graph.V.hasLabel("class:xxx")
but they're not working either.
Thanks for help :)
Edit:
Now i see, that I can use hasLabel
stripping first two characters of my class, because of prefixes used by you(V_, E_). Is there any way of configuration, so I can disable these prefixes?
Moreover such call rise a warning
WARNING: scanning through all vertices without using an index for Traversal [OrientGraphStep(vertex,[~label.eq(x)])]
graph.getVerticesOfClass("xxx")
doesn't have such problem. Should I add some index manually?
Sorry for the late reply, I'm only just back from holidays.
You can configure this behaviour (prefixing V_ and E_) on OrientGraphFactory.setLabelAsClassName(boolean)
Are you using an existing orientdb that was not created with this driver?
No problem, I hope you've had happy holidays.
Yes, I'm using existing DB. I prefer to create a schema by script rather than by code.
Thanks for your help :)
Hi,
Why I have to query like this to get vertices by class? graph.V.has("@class","xxx") graph.V.hasLabel("class:xxx")
not like this? (by greamlin-scala syntax) graph.V.has("xxx")
Is this difference come from nature of orientDB..?
...anyway, thx to your contributions very much!
has(String)
always checks for property values, not class names, this is true for all gremlin variants and databases. not sure if I understood you correctly...?
Oh, sorry.
I mean: hasLabel(string)
And I found it works fine after some test.
Anyway, I queried my class "A" using g. V. hasLabel("A")
and it seems works below too. g. V. hasLabel("class:A")
Is there any difference or better way between them?