Can't grab edges by id, but can grab vertices by id

19 lượt xem
Chuyển tới thư đầu tiên chưa đọc

Olav Laudy

chưa đọc,
13:38:26 22 thg 1, 201822/1/18
đến Gremlin-users
Hi,


This is my sample db:

['Vertex:',
 {'id': 91, 'label': 'object1', 'properties': {'name': 1}},
 'Vertex:',
 {'id': 93, 'label': 'object1', 'properties': {'name': 2}},
 'Vertex:',
 {'id': 95, 'label': 'object1', 'properties': {'name': 3}}]

['Edge:',
 {'id': 97,
  'inV': 93,
  'inVLabel': 'object1',
  'label': 'obs1',
  'outV': 91,
  'outVLabel': 'object1',
  'properties': {'x': 'x1'}},
 'Edge:',
 {'id': 98,
  'inV': 93,
  'inVLabel': 'object1',
  'label': 'obs1',
  'outV': 91,
  'outVLabel': 'object1',
  'properties': {'x': 'x2'}},
 'Edge:',
 {'id': 99,
  'inV': 95,
  'inVLabel': 'object1',
  'label': 'obs1',
  'outV': 93,
  'outVLabel': 'object1',
  'properties': {'x': 'x3'}}]


I can do:

g.V(91) or 
g.V().has(id,91)
g.V().hasId(91)

resulting in:

['Vertex:', {'id': 91, 'label': 'object1', 'properties': {'name': 1}}]


by I can't  do:

g.E(97) or 
g.E().has(id,97)
g.E().hasId(97)

They all come back as {'@value': [], '@type': 'g:List'}


I know that using id is not the best way to grab an object, but for quick testing purposes, it can be very handy (as per Tinkerpop documentation where that happens all the time).

Also, I know how the 'true' argument in .valueMap(true) returns all system ids, but I'm unable to refer to them:

e.g., for this edge, give me inV or inVLabel. How do I do that?



Thanks! 






Daniel Kuppitz

chưa đọc,
14:13:24 22 thg 1, 201822/1/18
đến gremli...@googlegroups.com
Can you provide more information? Are you using TinkerGraph? Which version? How did you create the graph?
A simple test worked fine for me:

gremlin> g = TinkerFactory.createModern().traversal()
==>graphtraversalsource[tinkergraph[vertices:6 edges:6], standard]
gremlin> g.E()
==>e[7][1-knows->2]
==>e[8][1-knows->4]
==>e[9][1-created->3]
==>e[10][4-created->5]
==>e[11][4-created->3]
==>e[12][6-created->3]
gremlin> g.E(7)
==>e[7][1-knows->2]

Usually, these kinds of problems are datatype related. Check the type of your edge ids.

gremlin> g.E().id().next().class
==>class java.lang.Integer

If it's a Long, try: g.E(97L)

Cheers,
Daniel


--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/665e8d6d-e26d-4f6f-8204-0d3f3e6f3529%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Olav Laudy

chưa đọc,
15:06:01 22 thg 1, 201822/1/18
đến Gremlin-users
That's it!  g.E(97L) works!

I'm using Tinkergraph, with Gremlin 3.3.1

ok...it's due to my own doing:

I copied some stuff from the internet to populate my tinkergraph-empty properties (mainly to store the graph upon exit). it contains:

gremlin.graph=org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph
gremlin.tinkergraph.vertexIdManager=LONG
gremlin.tinkergraph.graphLocation=graph.graphml
gremlin.tinkergraph.graphFormat=graphml


and indeed....it when I specify that the vertexIdManager is set to LONG, I can only hope that it respects that setting.

Thank you Daniel!




To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
Trả lời tất cả
Trả lời tác giả
Chuyển tiếp
0 tin nhắn mới