Table of Contents

Description

Executes graph query using the selected project's graph connection and returns the result of the query.

Connection

Attributes

There are currently no special attributes supported for this driver.

Parameters

Name

Description

Required

Default

project_id

Id of a project. The graph connection from this project will be used to create the connection.

yes

no default

query_empty_value

A string that represents what will be returned if a null value of some property is returned from the graph connection.

no

Returns the name of the property

Query

Executes the graph query using the currently enabled graph connection of a project (identified by project_id) and returns the result of the query. Used for the read statements.

You can use any <script> in the body of the query to process every record returned by the query one by one. Properties in the query result are accessible as "$property_key".

Special tokens

Use $record to reference the result of the query that is not a token. For example count queries return single item, which is referenced by subsequent script (see gremlin example below)

Script

Executes any read or write statements. Used for "write" statements mainly. Statement in each <script> is executed in a separate transaction. If there is some error during the execution of any <script> then the rollback is called. The Rollback is not working if you use Cypher "USING PERIODIC COMMIT".

Examples

Query example: Executes a query and every record from the result is written into a text file. The script element is used in the Query element to process every record of the result.

<!DOCTYPE etl SYSTEM "https://scriptella.org/dtd/etl.dtd">
<etl>
<description>Test neo4j query</description>
<connection id="neo4j" driver="graphConnection">
project_id=1
query_empty_value=
</connection>
<connection id="out" driver="text" url="d:\\testfile.txt"/>
<query connection-id="neo4j">
MATCH (n:Ci) RETURN id(n) as id, n.logicalName as logicalName LIMIT 25
<script connection-id="out">$rownum;$id;$logicalName</script>
</query>
</etl>

Script example: Executes Cypher statement.

<!DOCTYPE etl SYSTEM "https://scriptella.org/dtd/etl.dtd">
<etl>
<description>Test neo4j query</description>
<connection id="neo4j" driver="graphConnection">
project_id=1
      query_empty_value=
</connection>
<script connection-id="neo4j">
CREATE INDEX ON :Ci(logicalName)
</script>
</etl>

Script example: Executes a gremlin statement. 

<!DOCTYPE etl SYSTEM "https://scriptella.org/dtd/etl.dtd">
<etl>
<description>Test gremlin query</description>
<connection id="gremlin" driver="graphConnection">
project_id=1
      query_empty_value=######
</connection>
 
<connection id="logInfo" driver="log">
level=INFO
</connection>
<query connection-id="gremlin">
g.V().count()
<script connection-id="logInfo">current total: $record</script>
</query>
</etl>