Neo4jQuery

Labels: :IA_Function:IA_Neo4jQuery

The Neo4jQuery executes a Cypher statement and returns its results.

Properties

Key Description Default value Possible values
cypher The Cypher statement that has to be executed. any valid Cypher
params.myParameter Parameters that are to be passed to the Cypher statement. a literal value, <required>
store The Neo4j graph store against which the cypher statement is to be executed. application name of a configured Neo4j store
name The name of the Function. Neo4jQuery
process Determines whether the query result should be processed to a nodes and relations. false true|false 0|1

All properties can also be passed as parameters via an incoming trigger. To do so, include a property key on the incoming trigger with a $ or # as a prefix.


Events

A Neo4jQuery has the following events:

success

This event is triggered when the Neo4jQuery function execures successfully, and creates an event object of the following structure:

{
  "type": "success",     // the event type
  "data": [],            // array of data as it was returned by Neo4j
  "processed": {         // data after processing in case  process=true
    "labels": [],        // array of Neo4j labels present
    "nodes": [],         // array of nodes
    "relations": [],     // array of relations
    "reltypes": [],      // arry of relation types
    "private": {         // number of nodes /relations not being transferred to client
      "nodes": 0,
      "relations":0
    },
  },
  "meta": {                       // meta information
    "columns": ["path"],          // array of columns returned in result
    "cypher": "MATCH  .... ",     // Cypher statement
    "memory": 12.345,             // memory used in bytes
    "nodecount": 2,               // count of nodes returned
    "params": [],                 // array of parameters and values 
    "processData": true,          // status of processData
    "relcount": 1,                // count of relations returned
    "status": "ok",               // status of Cypher statement was executed
    "store": "application",       // store against which the 
    "timing": {                   // timing of query in ms
      "data": 25,
      "processing": 6,
      "total": 31
    },
  },
  "_function": {},
  "_global": {}
}

functionExecuted

This event is triggered when the Neo4jQuery function is executed, and creates an event object(%) of the following structure:

{
   "type": "functionExecuted",                  // type
   "data": {},                                  // data
   "_function": {},                             // _function info
   "_global": {}                                // _global info
}

Example

Imagine the following interaction graph:

NetworkView example

When you run this example, the MyQuery1 returns a list of labels and counts in MyTable1. When you click on a row with a count < 5, it displays the nodes in MyNetworkView. Otherwise, a list of names is displayed in MyTable2.

The first IA:Neo4jQuery node MyQuery1, has a type:success trigger that tp the IA:TableView node MyTable1. The trigger maps the (%).data element of the event data of the success event to the #data property of MyTable1.

MyTable1 has a type:rowClick trigger to a IA:Neo4jQuery MyQuery2. This tigger maps the (%).data.label element of the event data of the rowclick event to the $params.selectedLabel property of MyQuery2.

MyQuery2 takes $params.selectedLabel as parameter for the statement in the cypher property.

When MyQuery2 executes successfully, the success event occurs. To determine which triggers should be executed, the matching criteria on the outgoing [:TRIGGER] relations are considered:

  • (%).data[0].destination
  • type

One trigger executes when type:success AND (%).data[0].destination:NetworkView . This trigger maps (%).processed.nodes and (%).processed.relations to the #nodes and relations properties of the IA_NetworkView MyNetworkView.

The other trigger executes when type:success AND (%).data[0].destination:TableView . This trigger maps (%).data[#].name to #data property of the IA_TableView MyTable2.


* not available in Community Edition