Re: [Neo4j] How to Execute a Gremlin Script pointing to Neo4J server using Groovy?

94 views
Skip to first unread message

Peter Neubauer

unread,
Jul 17, 2012, 6:15:43 AM7/17/12
to ne...@googlegroups.com

You have to iterate through the pipe at the end of your script on order to return the results.

For storing stuff , either just load a file from disk and do eval within your script, or write a plugin that does it?

/peter

Send from mobile.

On Jul 17, 2012 11:04 AM, "Vijay" <vk....@gmail.com> wrote:

Hi,

I am trying to execute a Gremlin Script pointing to Neo4j server using Groovy.

I got the  status Code, but I couldn't get the response of the executed query.             

 def http = new groovyx.net.http.HTTPBuilder()

              http.post(    uri: 'http://localhost:7474/db/data/ext/GremlinPlugin/graphdb/execute_script',

                           body: 'script=' + 'g.v(1).out',

                           requestContentType: URLENC)

              { resp -> println "Success! ${resp.status}" }


I got the response code as "200" but I couldn't get the result of the executed Query.

Is there any possible way to store the Gremlin Script in Neo4j server and to invoke it using Groovy(Similar to invoke of a stored Procedure from Java end).


Thanks

Vijay


Marko Rodriguez

unread,
Jul 17, 2012, 11:05:58 AM7/17/12
to ne...@googlegroups.com
Hi,

As Peter says, do: g.v(1).out.toList()

Also, to your point about storing the script on Neo4j Server. I don't know the current "best practices" for Neo4j Server, but my technique is to create extensions that hardcode my production-used Gremlin traversals. This way, I simply pass in parameters and get back results. No knowledge of the Gremlin query in the background.

HTH,
Marko.
Reply all
Reply to author
Forward
0 new messages