unipop-graph / unipop

Data Integration Graph
Apache License 2.0
203 stars 35 forks source link

Failed with gremlin traversal on Edge operation #114

Open zxnblake opened 6 years ago

zxnblake commented 6 years ago

HI @seanbarzilay:

I am trying the gremlin traversal with unipop-elastic. I can load data from ES into graph, and the code < graph.traversal().V("1").next().value("name") > is working well, but the following code is not working: GraphTraversal<Edge, Edge> et = graph.traversal().E("1"); Edge edges = et.next(); It always throws out the following error: java.util.NoSuchElementException org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal.next(DefaultTraversal.java:204) at org.unipop.elastic.tests.ConfigurationTests.upsertConfiguration(ConfigurationTests.java:40) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) When I debug into the code(ElasticClient.execute(action)), I can see that the query for edge with id=1 is successful, and I can see the following search result with json: {"took":1,"timed_out":false,"_shards":{"total":1,"successful":1,"failed":0},"hits":{"total":1,"max_score":1.0,"hits":[{"_index":"edge","_type":"default","_id":"1","_score":1.0,"_source":{"inVertex":{"ref":"true","id":"548","label":"person"},"label":"knows","outVertex":{"ref":"true","id":"1","label":"person"}}}]}} It seems that the edge and its inVertex and outVertex have been fetched from ES store already. Why it always failed in executing the et.next(); or et.inV().next()?

zxnblake commented 6 years ago

I have found the issue: we should provide the "outId" and "inId" property in the edge mapping both in config file and the edge index in ES. The code will try to find the outId/inId property when forming an edge in the graph. The following is my current config file ( I am using the embedded ES in Crate ): { "class": "org.unipop.elastic.ElasticSourceProvider", "clusterName": "crate", "addresses": "http://localhost:4200", "vertices": [ { "index": "vertex", "type": "default",
"id": "@_id", "label": "person", "properties": { }, "dynamicProperties": true } ], "edges": [ { "index": "edge", "type": "default",
"id": "@_id", "label": "knows", "properties": { }, "dynamicProperties": { }, "outVertex": { "ref": true, "id": "", "label": "person", "properties": {} }, "inVertex": { "ref": true, "id": "", "label": "person", "properties": {} } } ] }

seanbarzilay commented 6 years ago

@zxnblake I didn't understand you completely but in your mapping file you haven't provide id properties for both inVertex and outVertex

zxnblake commented 6 years ago

Sorry for the wrong config file.. The following one is working:

{ "class": "org.unipop.elastic.ElasticSourceProvider", "clusterName": "jiesi-crate-userprofile", "addresses": "http://172.28.235.41:20100", "vertices": [ { "index": "user_profile_jsf_jim", "type": "default",
"id": "@_id", "label": "@_type", "properties": { }, "dynamicProperties": true } ], "edges": [ { "index": "user_relation", "type": "knows",
"id": "@_id", "label": "@_type", "outId": "", "inId": "", "properties": { }, "dynamicProperties": { "excludeFields": ["outId", "inId"] }, "outVertex": { "ref": true, "id": "@outId", "label": "default", "properties": {} }, "inVertex": { "ref": true, "id": "inId", "label": "default", "properties": {} } } ] }

seanbarzilay commented 6 years ago

You're missing a "@" in your inVertex id property