datastax - Unable to print node properties in DSE graph -
apologies might basic question on topic new gremlin/dse graph , tried many ways extract data inserting graph somehow unable make work.
here have: 1. graph allow_scans set true 2. schema propertykey , vertexes defined , materialized index on nodeid of vertexes.
there no relationships right now, vertexes data points.
i wrote program insert nodes dse graph working response below after program created every vertex:
result({u'id': {u'out_vertex': {u'community_id': 853347840, u'~label': u'vertex', u'member_id': 14}, u'~type': u'name', u'local_id': u'00000000-0000-8012-0000-000000000000'}, u'value': u'amount', u'label': u'name'})] ok nodes inserted, want extract them , print names: did:
g.v().haslabel('field').has('nodeid','2559b635f077e86c7370ab1c4c798a06').values('name'); above failed blank result. mean runs null output there no error there no output. (null in gremlin-console , 'success - no results' in datastax studio)
then came across documentation graph not know if 'has' return 1 node or more, used next iterating per documentation , tutorials:
g.v().haslabel('field').has('nodeid','2559b635f077e86c7370ab1c4c798a06').next().values('name'); even failed
org.apache.tinkerpop.gremlin.driver.exception.responseexception
(datastax studio doesnt show more information) - how can debug further?
i came across lambda approach in use map :
g.v().haslabel('field').has('nodeid','2559b635f077e86c7370ab1c4c798a06').map{it.get().value('name')}; which responded 'it' not being defined.
(i tried valuemap - not sure if required)
what doing wrong find , print properties values of node?
any directions or query can me extract names , other properties? multi-step query? don't think should complicated.
update:
as per answer following traceback:
gremlin> :> g.v().haslabel('field').has('nodeid','2559b635f077e86c7370ab1c4c798a06').valuemap(true).next(); org.apache.tinkerpop.gremlin.groovy.plugin.remoteexception type ':help' or ':h' help. display stack trace? [yn]y org.apache.tinkerpop.gremlin.groovy.plugin.remoteexception @ org.apache.tinkerpop.gremlin.console.groovy.plugin.driverremoteacceptor.submit(driverremoteacceptor.java:170) @ org.apache.tinkerpop.gremlin.console.commands.submitcommand.execute(submitcommand.groovy:41) @ org.codehaus.groovy.tools.shell.shell.execute(shell.groovy:104) @ org.codehaus.groovy.tools.shell.groovysh.super$2$execute(groovysh.groovy) @ sun.reflect.generatedmethodaccessor15.invoke(unknown source) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:498) @ org.codehaus.groovy.reflection.cachedmethod.invoke(cachedmethod.java:93) @ groovy.lang.metamethod.domethodinvoke(metamethod.java:325) @ groovy.lang.metaclassimpl.invokemethod(metaclassimpl.java:1215) @ org.codehaus.groovy.runtime.scriptbytecodeadapter.invokemethodonsupern(scriptbytecodeadapter.java:132) @ org.codehaus.groovy.tools.shell.groovysh.executecommand(groovysh.groovy:259) @ org.apache.tinkerpop.gremlin.console.gremlingroovysh.execute(gremlingroovysh.groovy:84) @ org.codehaus.groovy.tools.shell.shell.leftshift(shell.groovy:122) @ org.codehaus.groovy.tools.shell.shellrunner.work(shellrunner.groovy:95) @ org.codehaus.groovy.tools.shell.interactiveshellrunner.super$2$work(interactiveshellrunner.groovy) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:498) @ org.codehaus.groovy.reflection.cachedmethod.invoke(cachedmethod.java:93) @ groovy.lang.metamethod.domethodinvoke(metamethod.java:325) @ groovy.lang.metaclassimpl.invokemethod(metaclassimpl.java:1215) @ org.codehaus.groovy.runtime.scriptbytecodeadapter.invokemethodonsupern(scriptbytecodeadapter.java:132) @ org.codehaus.groovy.runtime.scriptbytecodeadapter.invokemethodonsuper0(scriptbytecodeadapter.java:152) @ org.codehaus.groovy.tools.shell.interactiveshellrunner.work(interactiveshellrunner.groovy:124) @ org.codehaus.groovy.tools.shell.shellrunner.run(shellrunner.groovy:59) @ org.codehaus.groovy.tools.shell.interactiveshellrunner.super$2$run(interactiveshellrunner.groovy) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:498) @ org.codehaus.groovy.reflection.cachedmethod.invoke(cachedmethod.java:93) @ groovy.lang.metamethod.domethodinvoke(metamethod.java:325) @ groovy.lang.metaclassimpl.invokemethod(metaclassimpl.java:1215) @ org.codehaus.groovy.runtime.scriptbytecodeadapter.invokemethodonsupern(scriptbytecodeadapter.java:132) @ org.codehaus.groovy.runtime.scriptbytecodeadapter.invokemethodonsuper0(scriptbytecodeadapter.java:152) @ org.codehaus.groovy.tools.shell.interactiveshellrunner.run(interactiveshellrunner.groovy:83) @ org.codehaus.groovy.vmplugin.v7.indyinterface.selectmethod(indyinterface.java:232) @ org.apache.tinkerpop.gremlin.console.console.<init>(console.groovy:152) @ org.codehaus.groovy.vmplugin.v7.indyinterface.selectmethod(indyinterface.java:232) @ org.apache.tinkerpop.gremlin.console.console.main(console.groovy:401) i able similar operations in graph. wrong graph?
update 2
my graph vertices wrongly defined.
the key drill down solution in ~label in result. points vertex instead should field
while defining data insert team had put label in quotes when had put mention label without quotes. hence not able traverse nodes.
you need make sure iterate traversal. commonly use either:
iterate()0 resultnext()1 resulttolist()many results
i'd guess nodeid unique, try this:
g.v().haslabel('field').has('nodeid','2559b635f077e86c7370ab1c4c798a06'). values('name').next(); if you're interested in of properties on vertex, try:
g.v().haslabel('field').has('nodeid','2559b635f077e86c7370ab1c4c798a06'). valuemap(true).next();
Comments
Post a Comment