Skip to content

Scripts and queries

Max De Marzi edited this page Jun 17, 2013 · 2 revisions

Groovy scripts:

@neo.execute_script("g.v(0)")                              # sends a Groovy script (through the Gremlin plugin)
@neo.execute_script("g.v(id)", {:id => 3})                 # sends a parameterized Groovy script (optimized for repeated calls)

Cypher queries:

@neo.execute_query("start n=node(0) return n")             # sends a Cypher query (through the Cypher plugin)
@neo.execute_query("start n=node({id}) return n", {:id => 3}) # sends a parameterized Cypher query (optimized for repeated calls)
@neo.execute_query("start n=node({id}) return n", {:id => 3}, {:stats => true}) # get the statistics of a query
@neo.execute_query("start n=node({id}) return n", {:id => 3}, {:profile => true}) # get the profile of a query
@neo.execute_query("start n=node({id}) return n", {:id => 3}, {:stats => true, :profile => true}) # get the statistics and profile of a query

Example Response:

{
  "columns" : [ "labels(n)" ],
  "data" : [ [ [ "foo" ] ] ],
  "stats" : {
    "relationships_created" : 0,
    "nodes_deleted" : 0,
    "relationship_deleted" : 0,
    "indexes_added" : 0,
    "properties_set" : 0,
    "constraints_removed" : 0,
    "indexes_removed" : 0,
    "labels_removed" : 1,
    "constraints_added" : 0,
    "labels_added" : 1,
    "nodes_created" : 0,
    "contains_updates" : true
  },
 "plan" : {
    "args" : {
      "returnItemNames" : [ "type(r)", "n.name?", "n.age?" ],
      "_rows" : 2,
      "_db_hits" : 0,
      "symKeys" : [ "x", "n", "n.name?", "n.age?", "type(r)", "r" ]
    },
    "dbHits" : 0,
    "name" : "ColumnFilter",
    "children" : [ {
      "args" : {
        "_rows" : 2,
        "_db_hits" : 4,
        "exprKeys" : [ "type(r)", "n.name?", "n.age?" ],
        "symKeys" : [ "n", "x", "r" ]
      },
      "dbHits" : 4,
      "name" : "Extract",
      "children" : [ {
        "args" : {
          "trail" : "(x)-[r WHERE true AND true]->(n)",
          "_rows" : 2,
          "_db_hits" : 3
        },
        "dbHits" : 3,
        "name" : "TraversalMatcher",
        "children" : [ ],
        "rows" : 2
      } ],
      "rows" : 2
    } ],
    "rows" : 2
  }
}
Clone this wiki locally