Skip to main content
Skip table of contents

Import from a Graph Database (Neo4j)

You can pull data directly from a Neo4j graph database connected to a GraphXR project. The data will include its current schema, that is, its defined categories, relationships, and properties. You can pull data in the following ways:

  • Enter and run a Cypher query in the Cypher tab of the Query panel.

  • Use the search bar to enter a full text keyword search of indexed node properties and pull the resulting nodes from the database.

  • Pull nodes or edges 25 at a time by selecting a category or relationship in the Project panel and clicking Pull.

  • Use Expand in the context toolbar to pull data connected by specified relationships to selected nodes in the graph.

GraphXR also includes the Visual Query Builder extension for no-code Cypher queries using visual building blocks. This lets you access Cypher’s most commonly used pattern matching capabilities without needing to learn Cypher code in detail.

Import using a Cypher query

Cypher is a query language for graph data developed in tandem with Neo4j. It has become a standard for querying graph databases. In addition to queries for basic patterns, Cypher also includes complex selection, transformation, and graph database maintenance functions.

For information about Neo4j and the Cypher query language, refer to Neo4j’s For Beginners - Cypher Query language and the Neo4j Cypher Manual.

Cypher query basics

A Cypher query returns graph data that match a specified graph pattern.All GraphXR projects include a basic query that pulls the first 1000 connected nodes from the database:

CODE
MATCH (n)-[r]-(m) RETURN * LIMIT 1000

This query will MATCH any pattern of nodes n and m connected by any relationship r, and RETURN the first 1000 found. The LIMIT is set because this query will likely return a large amount of data.

A more specific, but still basic query for categories and relationships of interest is the following query for Game of Thrones data with the pattern (Characters)-[belongs_to]-(House):

CODE
MATCH (c:Characters)-[r:belongs_to]-(h:House) RETURN *

This query will MATCH any pattern of Characters and House nodes connected by a belongs_to relationship and RETURN all the matching graph patterns. The variables c, r, and h are used here to simplify further query specifications.

Cypher also provides the ability to set one or more parameters in a query, so that a user can specify property values that must also be matched. For example, the following query lets a user specify a House name when the query is run:

CODE
MATCH (c:Characters)-[r:belongs_to]-(h:House{houseName: $houseName}) RETURN *

In GraphXR, you can:

  • Enter a Cypher query and click the play icon on the right to run it. A query can include one or more parameters for property values to be entered when the query is run.

  • Save a a query by clicking the + (plus) icon. You must enter a name, which can either be the query itself, or a descriptive name of your choosing. The saved query appears on a drop down menu, and is immediately available to all users of the project.

  • Run a saved query by selecting it on the drop down and clicking the play icon.

To import data using a Cypher query:

  1. Click the Query panel icon. It opens with the Cypher tab displayed.

  2. Either enter a Cypher query , or select a saved query using the v icon (Collection list).

  3. Click the Load Inner Relationship checkbox to include the relationships between the nodes pulled by a query.

  4. Click the > icon (Run Cypher) to query the connected database.
    If one or more parameters have been set in the query, enter a property value for each in the dialog, and click Confirm.
    The nodes and connecting edges matching the query appear in the project space.

  5. If you entered a new query, you can optionally click the + icon (Add to Collection) to save it.
    An Alias Name dialog displays.

  6. Either enter a descriptive name for the query, such as CharactersHouses, or simply copy the query and paste it into the dialog. Then click Confirm to add the query to the saved list.

Pull data by full-text keyword search

You can use the search field at the top right corner of the graph space to import data using full-text keyword search. The icon at the right of the search field lets you toggle between Searching from Database or Searching from Graph, to search the data already in the graph space.

To search a Neo4j database, the search terms must first be indexed in the database. To review and edit search terms, click the Config Search Index icon to the right of the database icon.

To configure the search index:

  1. Click the gear icon next to the search bar to display the the Database Text Search Index Configuration dialog.

    The dialog lists the categories in the connected database, and their properties.

  2. Click Refresh Property to make sure all the properties in the database are listed.

  3. Select properties you want to index. You can either
    Click the All Category Properties checkbox to select all properties.
    OR
    Click checkboxes to index selected properties.

  4. Click Submit Index Task to index the database search terms.
    A message displays indicating that the indexing task was successful.

  5. Click the X at the upper right to close the dialog.

To pull data using full-text keyword search:

  1. Enter one or more search terms in the search bar at the top left corner of the graph space, and press return. You can search for exact indexed property values or partial text strings.

    • Use asterisks * to define a search for partial property values (e.g. Jo* for John, Jonathan, Josephine). Position asterisks to search for values that start with, end with, or contain the specified string (e.g. *Jo, Jo*, or *Jo*).

    • Terms separated by a space use OR logic. Nodes with indexed property values matching any one of the terms will be returned. (e.g. Inspector Sergeant for nodes that include an exact property value of Inspector OR Sergeant).

    • Terms separated by the word AND return only nodes with indexed property values that match all terms. (e.g. Inspector AND D* for nodes with an exact property value of Inspector, and a property value that starts with D (case-insensitive).
      Search results are listed beneath the search bar for each category.
      Nodes matching the search keyword appear below the search field, listed by category in alphabetical order.

  2. Click the arrow to the left of a category to view individual nodes. If more than five nodes are returned for a category, use the arrow selector at the right to navigate through the list and locate nodes you want to import.

  3. Click a list item to add the node to the graph space.
    OR
    Click the + icon to the right of the category label to import all the matching nodes of that category.
    TIP: When you add data, the nodes remain selected in the graph space until you add more data. If you want to immediately remove the data you just imported, press delete while the nodes are still selected.

  4. Click the x in the search bar to clear the search and return to the graph space.

Searching from the graph vs Searching from the database
Once data are imported, you can click the toggle to the right of the search bar to switch to a search of the graph. Searching imported data in the graph can help quickly narrow down a search, since matching nodes are actively highlighted as you enter search terms.

However, a graph search works differently than a database search in the following ways:

  • Partial text is entered without asterisks.

  • AND logic is not recognized. (Any space between search terms is still recognized as OR logic.)

Pull data by Category or Relationship

You can pull 25 nodes at a time from a category or relationship that appears in the Category or Relationship tab of the Project panel.

This may be useful for initial data exploration; however a query provides more control of sampling.

To pull data by Category:

  1. Click the Project panel icon and Category tab.

  2. Click one of the Category items to select it.

  3. Click Pull to pull 25 nodes associated with that category, and any edges that connect the nodes.

  4. For added samples, click again, as many times as you want.

To pull data by Relationship:

  1. Click the Project panel icon and Relationship tab.

  2. Click one of the Relationship items to select it.

  3. Click Pull to pull 25 edges associated with that relationship, the connected nodes, and all the other edges connected to those nodes.

  4. For added samples, click again, as many times as you want.

Pull data using Expand

You can select a node or group of nodes in the project space, and use Expand in the right-click menu or from the toolbar menu to pull additional data from the graph database that is connected through specific relationships with the currently selected nodes.

To pull data using Expand:

  1. Select one or more nodes in the graph space, then select Expand from the right-click menu, or click the Expand toolbar icon to display the Expand with relationships dialog.

  2. Click the checkbox next to a relationship name to pull nodes and edges connected by that relationship.
    OR
    Click All to pull nodes and edges with all relationships to the selected nodes. To limit the number of nodes, enter a number in the Limit field.

  3. Set additional options for expanding the graph:

    - Click the Only among selected nodes checkbox to expand relationships only for the selected nodes.
    - Specify Directional relationships using the dropdown menu. You can choose All directions, only nodes connected by relationships From the selected nodes, To the selected nodes, or only those with a Bidirectional relationship.
    - Increase Repeat relationship times, which automatically repeats the expand operation, enabling you to pull in the limit of 1000 edges and their connected nodes repeatedly.

  4. Click the Expand button.

    An Expand Next Page dialog indicates the number of items successfully expanded. You can
    - Click Expand More to pull the next 1000 connected items. This lets you pull in all the data in the database that have the specified connections without needing to return to the Expand with relationships dialog.
    - Click Cancel (or simply click the X at the upper right) to close the dialog.

    Additional nodes and their relationships are pulled into the graph. In the example below, All relationships were selected, and additional nodes with edges connected to the selected Character and House nodes were pulled from the Neo4j database. Once no additional nodes are connected to the selected nodes by the specified relationships, a message displays that all relationships are fully expanded.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.