If you often need to handle data of a Neo4j database, then you may want to centralize the connection to the Neo4j database and the schema details in the Metadata folder in the Repository tree view.
Only the Neo4j remote server is supported.
When you use V3.2.X, only tNeo4jInput and tNeo4jRow can reuse the connection
Do not use a 2.X.X version and a 3.X.X version in the same Job. Otherwise, class conflict issues occur.
The Neo4j metadata setup procedure is made of two separate but closely related major tasks:
Create a connection to a Neo4j database.
Retrieve Neo4j schemas of interest.
All the required external modules that are missing in Talend Studio due to license restrictions have been installed. For more information, see the Talend Installation Guide.
You are familiar with Cypher queries for reading data in Neo4j.
The Neo4j server is up and running.
In the Repository tree view, expand the Metadata node, right-click NoSQL Connection, and select Create Connection from the contextual menu. The connection wizard opens up.
In the connection wizard, fill in the general properties of the connection you need to create, such as Name, Purpose and Description.
The information you fill in the Description field will appear as a tooltip when you move your mouse pointer over the connection.
When done, click Next to proceed to the next step.
Select Neo4j from the DB Type list, and specify the connection details:
Enter the authentication information to connect to the remote Neo4j server to be used. Since Neo4j 2.2, user credentials are always required.
Specify the root URL in the Server URL field.
Click the Check button to make sure that the connection works.
Click Finish to validate the settings.
The newly created Neo4j database connection appears under the NoSQL Connection node in the Repository tree view. You can now drop it onto your design workspace as a Neo4j component, but you still need to define the schema information where needed.
Next, you need to retrieve one or more schemas of interest for your connection.
In this step, we will retrieve the schema of interest from the connected Neo4j database.
In the Repository view, right-click the newly created connection and select Retrieve Schema from the contextual menu.
The wizard opens a new view for schema generation based on a Cypher query.
In the Cypher field, enter your Cypher query to match the nodes and retrieve the properties of interest.
If your Cypher query includes strings, enclose your strings between single quotation marks instead of double ones, which will cause errors in Neo4j components dropped from your centralized metadata.
In this example, the following query is used to match nodes labelled Employees and retrieve their properties ID, Name, HireDate, Salary, and ManagerID as schema columns:
MATCH (n:Employees) RETURN n.ID, n.Name, n.HireDate, n.Salary, n.ManagerID;
If you want to retrieve all the properties of nodes labelled Employees in this example, you can enter a query like this:
MATCH (n:Employees) RETURN n;
MATCH (n:Employees) RETURN *;
Click Next to proceed to the next step of the wizard where you can edit the generated schema.
Modify the schema if needed. You can rename the schema, and customize the schema structure according to your needs in the Schema area.
The tool bar allows you to add, remove or move columns in your schema, or replace the schema with the schema defined in an XML file.
To add a new schema, click the Add Schema button in the Schema panel, which creates an empty schema for you to define.
To remove a schema, select the schema name in the Schema panel and click the Remove Schema button.
Click Finish to complete the schema creation. The result schema appears under your Neo4j connection in the Repository view. You can now drop the connection or any schema node under it onto your design workspace as a Neo4j component, with all the metadata information automatically filled.
If you need to further edit a schema, right-click the schema and select Edit Schema from the contextual menu to open this wizard again and make your modifications.
If you modify the schemas, ensure that the data type in the Type column is correctly defined.