Writing data to Neo4j and creating indexes and relationships - 7.0

Neo4j

author
Talend Documentation Team
EnrichVersion
7.0
EnrichProdName
Talend Big Data
Talend Big Data Platform
Talend Data Fabric
Talend Open Studio for Big Data
Talend Real-Time Big Data Platform
task
Data Governance > Third-party systems > Database components > Neo4j components
Data Quality and Preparation > Third-party systems > Database components > Neo4j components
Design and Development > Third-party systems > Database components > Neo4j components
EnrichPlatform
Talend Studio

Procedure

  1. Click the tNeo4jOutput component and select the Component tab to open its Basic settings view.
  2. From the DB Version list, select Neo4J 2.X.X to enable node labeling.
  3. Define a Neo4j database connection. In this example, the Neo4j database is accessible in REST mode, so select the Remote server check box and specify the URL of the Neo4j server in the Server URL field, "http://localhost:7474/db/data" in this example.
  4. Double-click the tNeo4jOutput component or click the Mapping button on the component's Basic settings view to open the index and relationship mapping editor.
  5. With the name column selected from the schema panel, click the Index creation tab, click the [+] button to add a row in the table, and create an index named first_name on this column:
    • In the Name field, enter first_name between double quotation marks.

    • In the Key field, enter first_name between double quotation marks to give the index a key.

    Then click in the schema panel to validate your index creation.
  6. With the family column selected from the schema panel, click the Index creation tab, click the [+] button to add a row in the table, and create an index named family on this column:
    • In the Name field, enter family between double quotation marks.

    • In the Key field, enter family_name between double quotation marks to give the index a key.

    Then click in the schema panel to validate your index creation.
  7. With the family column selected from the schema panel, click the Relationship creation tab, click the [+] button to add a row in the table, and create a relationship named Spouse on this column based on the index named family:
    • In the Type field, enter Spouse between double quotation marks.

    • From the Direction list field, select either Outgoing or Incoming.

    • In the Index Name field, enter family between double quotation marks.

    • In the Index Key field, enter family_name between double quotation marks.

    Then click in the schema panel to validate your relationship creation, and click OK to close the mapping editor.
  8. Select the Use label (Neo4j > 2.0) check box and enter Families between double quotation marks in the Label name field so that the nodes to be created will be labeled Families.
  9. From the Data action list, select Insert or update, and set a reference key in the Index area that appears:
    • In Index name field, enter first_name between double quotation marks.

    • In Index key field, enter first_name between double quotation marks.

    • From Index value field, select name. As the Value field is left blank in index creation, the index value will be the value of the name column for each row.

    This way, when the Job is executed, nodes will be inserted or updated in the Neo4j database based on the first_name index: for each data row, if a node containing the same first name already exists in the database, the node will be updated; otherwise, a new node will be created.