Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed with gremlin traversal on Edge operation #114

Open
zxnblake opened this issue Nov 14, 2017 · 4 comments
Open

Failed with gremlin traversal on Edge operation #114

zxnblake opened this issue Nov 14, 2017 · 4 comments

Comments

@zxnblake
Copy link

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
Copy link
Author

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
Copy link
Member

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

@zxnblake
Copy link
Author

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
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants