August 17, 2023

tNeo4jOutputRelationship – Docs for ESB 5.x

tNeo4jOutputRelationship

tneo4joutputrelationship_icon32_white.png

Warning

This component will be available in the Palette of the studio on the condition that you have subscribed to
one of the Talend solutions with Big
Data.

tNeo4jOutputRelationship properties

Component family

Big Data / Neo4j

 

Function

tNeo4jOutputRelationship receives
data from the preceding component, and writes relationships into
Neo4j.

Purpose

tNeo4jOutputRelationship is used to
output relationship into a Neo4j database.

Basic settings

Use existing connection

Select this check box and in the Component List click the
relevant connection component to reuse the connection details you already defined.

 

DB version

Select the Neo4j version you are using, between Neo4J 1.X.X and Neo4J 2.X.X.

Note that Neo4j version 2.X.X is compatible only with Java 7 but
it offers support of advanced features such as node labels.

This list is not shown if the Use an existing connection
check box is selected.

Upon selecting a DB version, you will be prompted to install the corresponding database
driver JAR files if not yet installed. For more information on installing third-party
modules, see the Talend Installation and Upgrade Guide.

 

Remote server

Select this check box if you use a Neo4j REST server.

Warning

This check box appears only if you do not select the Use an existing connection check box.

 

Database path

If you use Neo4j in embedded mode, specify the path of data
file.

Warning

This field appears only if you do not select the Use an existing connection check box.

 

Schema and Edit schema

A schema is a row description. It defines the number of fields to be processed and passed on
to the next component. The schema is either Built-In or
stored remotely in the Repository.

Since version 5.6, both the Built-In mode and the Repository mode are
available in any of the Talend solutions.

Click Edit schema to make changes to the schema. If the
current schema is of the Repository type, three options are
available:

  • View schema: choose this option to view the
    schema only.

  • Change to built-in property: choose this option
    to change the schema to Built-in for local
    changes.

  • Update repository connection: choose this option to change
    the schema stored in the repository and decide whether to propagate the changes to
    all the Jobs upon completion. If you just want to propagate the changes to the
    current Job, you can select No upon completion and
    choose this schema metadata again in the [Repository
    Content]
    window.

 

 

Built-In: You create and store the schema locally for this
component only. Related topic: see Talend Studio
User Guide.

 

 

Repository: You have already created the schema and
stored it in the Repository. You can reuse it in various projects and Job designs. Related
topic: see Talend Studio User Guide.

When the schema to be reused has default values that are integers or functions, ensure that
these default values are not enclosed within quotation marks. If they are, you must remove
the quotation marks manually.

For more details, see https://help.talend.com/display/KB/Verifying+default+values+in+a+retrieved+schema.

 

Server url

If you use Neo4j in REST mode, specify the root URL.

Warning

This field appears only if you select the Remote server check box.

 

Shutdown after job (Only embedded
database)

Select this check box if you want to shutdown the Neo4j database
connection at the end of the Job.

Warning

This check box is available only if the Use an existing connection is selected.

 

Relationship type

Specify the relationship type to create for each row.

 

Start node / Index name

Specify the index name to query the starting node of the newest
relationship.

 

Start node / Index key

Specify the index key to query the starting node.

 

Start node / Index value

Select the index value to query the starting node.

 

Relationship direction

Select a relationship direction.

  • Outgoing: The
    relationship starts from the start node to the end node.

  • Incoming: The
    relationship starts from the end node to the start node.

 

End node / Index name

Specify the index name to query the ending node of the newest
relationship.

 

End node / Index key

Specify the index key to query the ending node.

 

End node / Index value

Select the index value to query the ending node.

  Mapping

Use this table to map relationship properties with the input
schema columns.

Advanced settings

Commit every

Enter the number of rows to be completed before committing batches
of nodes together the DB. This option ensures transaction quality
(but not rollback) and, above all, better performance at execution.

Warning

This option is only supported by the embedded mode of the
database. You can’t make transactions in REST mode.

 

Batch import

Select this check to activate the batch mode

Warning

This option is only supported by the embedded mode of the
database. Be very careful with the batch
import mode. Because this option is unsafe, perform a backup
before Job execution.

If you want more explanations about memory mapping configuration
of batch import, please refer to Neo4j documentation at: http://docs.neo4j.org/chunked/milestone/configuration-io-examples.html#configuration-batchinsert

 

Node store mapped memory

Type in the memory size in MB allocated to nodes.

 

Relationship store mapped memory

Type in the memory size in MB allocated to relationships.

 

Property store mapped memory

Type in the memory size in MB allocated to property.

 

String store mapped memory

Type in the memory size in MB in Mo allocated to strings.

 

Array store mapped memory

Type in the memory size in MB allocated to arrays.

 

tStatCatcher Statistics

Select this check box to gather the Job processing metadata at the
Job level as well as at each component level.

Global Variables

NB_LINE: the number of rows read by an input component or
transferred to an output component. This is an After variable and it returns an
integer.

ERROR_MESSAGE: the error message generated by the
component when an error occurs. This is an After variable and it returns a string. This
variable functions only if the Die on error check box is
cleared, if the component has this check box.

A Flow variable functions during the execution of a component while an After variable
functions after the execution of the component.

To fill up a field or expression with a variable, press Ctrl +
Space
to access the variable list and choose the variable to use from it.

For further information about variables, see Talend Studio
User Guide.

Usage This component is used as an output
component and it always needs an incoming link.
Limitation n/a

Scenario: Writing information of actors and movies to Neo4j with hierarchical
relationship

This scenario describes a Job that will import information about actors and movies
from two CSV files into a remote Neo4j database and then create relationship between the
actors and the movies based on another CSV file that describes the actors’ roles in the
movies.

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,

    • three tFileInputDelimited
      components, to read the input information of actors and
      movies,

    • two tNeo4jOutput components, to
      write information of movies and actors to the connected Neo4j
      database,

    • a tNeo4jOutputRelationship
      component, to create relationship between actors and movies,
      and

    • a tNeo4jClose component, to close
      the previous opened Neo4j connection at the end of Job
      execution.

  2. Link the first tFileInputDelimited to the
    first tNeo4jOutput component using a
    Row > Main connection. This sub-job will import the actors data
    into the Neo4j database.

  3. Link the second tFileInputDelimited
    component to the second tNeo4jOutput
    component using a Row > Main connection. This sub-job will import the
    movies data into the Neo4j database.

  4. Link the third tFileInputDelimited
    component to the tNeo4jOutputRelationship
    component using a Row > Main connection. This sub-job will create
    relationship between actors and movies.

  5. Link the sub-jobs using Trigger >
    On Subjob Ok connections.

  6. Label the components to better identify their roles in the Job.

    components-tneo4joutputrelationship_s1-1.png

Configuring the components

Opening a Neo4j database connection

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

    components-tneo4joutputrelationship_s1-2.png
  2. From the DB Version list, select
    Neo4J 2.X.X to enable node labeling.

  3. Select the Use a 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.

Importing the actors data into Neo4j

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

    components-tneo4joutputrelationship_s1-3.png
  2. In the File name/Stream field, specify
    the path to the CSV file that describes the actors’ names, the years they
    were born in, and their roles in the movies.

    The input CSV file used in this example is as follows:

  3. In the Header field, specify the number
    of rows to skip as header rows. In this example, the first row of the CSV
    file is the header row.

  4. Click the […] button next to Edit schema to open the [Schema] dialog box, and define the input schema based on
    the structure of the input file. In this example, the input schema is
    composed of two columns, name and
    born, both of type String.

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

    components-tneo4joutputrelationship_s1-4.png
  5. Click the first tNeo4jOutput component
    and select the Component tab to open its
    Basic settings view.

    components-tneo4joutputrelationship_s1-8.png
  6. 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.

  7. 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.

  8. 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 name on
    this column:

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

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

    Then click in the schema panel to validate your index creation, and click
    OK to close the mapping editor.

    components-tneo4joutputrelationship_s1-9.png
  9. Select the Use label (Neo4j > 2.0) check
    box and enter Actors between double
    quotation marks in the Label name field so
    that the nodes to be created will be labeled Actors.

Importing the movies data into Neo4j

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

    components-tneo4joutputrelationship_s1-5.png
  2. In the File name/Stream field, specify
    the path to the CSV file that contains the information of the movies.

    The input CSV file used in this example is as follows:

  3. In the Header field, specify the number
    of rows to skip as header rows. In this example, the first row of the CSV
    file is the header row.

  4. Click the […] button next to Edit schema to open the [Schema] dialog box, and define the input schema based on
    the structure of the input file. In this example, the input schema is
    composed of three columns, title (type
    String), released (type Date), and
    tagline (type String).

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

  5. Click the second tNeo4jOutput component
    and select the Component tab to open its
    Basic settings view.

    components-tneo4joutputrelationship_s1-10.png
  6. 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.

  7. 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.

  8. With the title 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 title on
    this column:

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

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

    Then click in the schema panel to validate your index creation, and click
    OK to close the mapping editor.

    components-tneo4joutputrelationship_s1-11.png
  9. Select the Use label (Neo4j > 2.0) check
    box and enter Movies between double
    quotation marks in the Label name field so
    that the nodes to be created will be labeled Movies.

Creating actor-movie relationship in Neo4j

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

    components-tneo4joutputrelationship_s1-7.png
  2. In the File name/Stream field, specify
    the path to the CSV file that describes the actors’ roles in the
    movies.

    The input CSV file used in this example is as follows:

  3. In the Header field, specify the number
    of rows to skip as header rows. In this example, the first row of the CSV
    file is the header row.

  4. Click the […] button next to Edit schema to open the [Schema] dialog box, and define the input schema based on
    the structure of the input file. In this example, the input schema is
    composed of three columns, actor,
    movie, and role, all of type String.

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

  5. Double-click the tNeo4jOutputRelationship
    component to open its Basic settings
    view.

    components-tneo4joutputrelationship_s1-12.png
  6. 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.

  7. In the Relationship type field, enter the
    type of relationship to be created, between double quotation marks. In this
    example, the relationship type is ACTED_IN, which will appear as the label of the relationship
    between nodes.

  8. Define the start and end nodes and the direction of the relationship to be
    created. In this example, the relationship will be created from Actors nodes, on which an index called
    name has been defined, to Movies nodes, on which an index called
    title has been defined.

    • Start node: enter name between double quotation marks in
      the Index name and Index key fields, and select the schema
      column name from the Index value list. As the Value field is left blank in index
      creation, the index value will be the value of column name for each row.

    • From the Relationship direction
      list, select Outgoing.

    • End node: enter title between double quotation marks in
      the Index name and Index key fields, and select the schema
      column title from the Index value list. As the Value field is left blank in index
      creation, the index value will be the value of column title for each row.

  9. Click the [+] button three times to add
    three rows in the Mapping table to define
    three properties of the relationship:

    • Actor, the value of which
      will be taken from the actor
      column of the schema,

    • Movie, the value of which
      will be taken from the movie
      column of the schema, and

    • Role, the value of which
      will be taken from the role
      column of the schema.

Executing the Job and checking the result

  1. Press Ctrl+S to save the Job, and press
    F6 or click Run on the Run tab to run
    the Job.

  2. In the address bar of your Web browser, enter the URL of the Neo4j
    database browser, http://localhost:7474/ in this example, and
    enter the following Cypher query in the command line to view the nodes with
    the specified relationship between them.

    As shown in the graphic view, Actors
    nodes are linked with Movies nodes via
    the relationship ACTED_IN, with
    properties as defined in the Job.

    components-tneo4joutputrelationship_s1-13.png

Document get from Talend https://help.talend.com
Thank you for watching.
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x