Scenario 1: Creating nodes with a label using a Cypher query - 6.1

Talend Components Reference Guide

EnrichVersion
6.1
EnrichProdName
Talend Big Data
Talend Big Data Platform
Talend Data Fabric
Talend Data Integration
Talend Data Management Platform
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for Big Data
Talend Open Studio for Data Integration
Talend Open Studio for Data Quality
Talend Open Studio for ESB
Talend Open Studio for MDM
Talend Real-Time Big Data Platform
task
Data Governance
Data Quality and Preparation
Design and Development
EnrichPlatform
Talend Studio

This scenario describes a Job that creates nodes with a label in an embedded Neo4j database using a Cypher query, and then displays some properties of the specified node on the console.

Adding and linking components

  1. Create a Job and add the following components to the Job by typing theirs names in the design workspace or dropping them from the Palette:

    • a tNeo4jConnection component, to open a connection to a Neo4j database,

    • a tNeo4jRow component, to create nodes in the Neo4j database with a Cypher query,

    • a tNeo4jIntput component, to read the specified properties of the created nodes,

    • a tLogRow component, to display the data on the Run console, and

    • a tNeo4jClose component, to close the Neo4j database connection established by the tNeo4jConnection component.

  2. Link the tNeo4jConnection component to the tNeo4jRow component using a Trigger > On Subjob Ok connection.

  3. Link the tNeo4jRow component to the tNeo4jIntput component using a Trigger > On Subjob Ok connection.

  4. Link the tNeo4jIntput component to the tLogRow component using a Row > Main connection.

  5. Link the tNeo4jIntput component to the tNeo4jClose component using a Trigger > On Subjob Ok connection.

Configuring the components

Configuring a Neo4j database connection and nodes creation

  1. Double-click the tNeo4jConnection component to open its Basic settings view on the Component tab.

  2. From the DB Version list, select Neo4J 2.X.X to enable node labeling support.

  3. In the Database path field, specify the directory for your data files, "E:/Talend/DB/Neo4j/data" in this example.

    In this example, you will use Neo4j in embedded mode; to connect to a remote Neo4j server via REST, click the Use a remote server check box and specify the URL of the Neo4j server.

  4. Double-click the tNeo4jRow component to open its Basic settings view on the Component tab.

  5. Select the Use an existing connection check box to reuse the Neo4j database connection opened by the tNeo4jConnection component, which is the only connection component used in this example.

  6. In the Query field, type in the Cypher query to be executed by the component.

    In this example, type in the following query to create two nodes with the label Managers and three properties - id, name, and position:

    "CREATE (a:Managers { id: 1, name: 'Gerald White', position: 'HR directory'})
    CREATE (b:Managers { id: 2, name: 'Jimmy Black', position: 'Sales manager'})"

    As this component does not have an input flow, leave the schema and the parameter settings blank.

Configuring data retrieving and display

  1. Double-click the tNeo4jInput component to open its Basic settings view.

  2. Select the Use an existing connection check box to reuse the connection opened by the tNeo4jConnection component.

  3. Click the [...] button next to Edit schema and define the schema corresponding to the node properties you want to retrieve and display. In this example, the schema is composed of two columns, name and position, both of type String.

    When done, click OK to close the [Schema] dialog box and propagate the schema to the next component.

    The defined schema columns automatically appear in the Mapping table.

  4. In the Query field, type in the Cypher query to match the data to read from the Neo4j database. In this example, use the following Cypher query to find the name and position of the manager whose ID is 2.

    "MATCH (ee:Managers{id:2}) RETURN ee.name, ee.position;"

    or

    "MATCH (ee:Managers) WHERE ee.id = 2 RETURN ee.name, ee.position;"
  5. Fill the Return parameter field for each schema column with a return parameter in double quotes to map the node properties in the Neo4j database with the schema columns.

  6. Double-click the tLogRow component to open its Basic settings view, and select the Table (print values in cells of a table) option to display the retrieved information in a table.

Executing the Job

  1. Press Ctrl+S to save the Job.

  2. Press F6 or click Run on the Run tab to run the Job.

    Two nodes are created in the Neo4j database based on the Cypher query, with the data files written in the specified directory, and the defined information is retrieved and displayed on the console.