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 respective tab 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.
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. Basically, a Cypher query returns graph data that match a specified graph pattern. Cypher also includes complex selection, transformation, and graph database maintenance functions.
In GraphXR, the Cypher tab of the Query panel lets you:
Enter a Cypher query and click the play icon on the right to run it.
Save a query by clicking the + (plus) icon. The saved query appears on a drop down menu.
Run a saved query by selecting it on the drop down and clicking the play icon.
All GraphXR projects include a basic query that pulls the first 100 connected nodes from the database:
MATCH (n)-[r]-(m) RETURN * LIMIT 100
This query will MATCH any pattern of nodes n and m connected by any relationship r, and RETURN the first 100 found. The LIMIT is set because this query will likely return a large amount of data.
You can also limit the number of returns in the Maximum return records allowed text box.
A more specific, but still very basic query for categories and relationships of interest is the following query for Game of Thrones data with the pattern (Characters)-[belongs_to]-(House):
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.
To import data using a Cypher query:
Click the Query panel icon. It opens with the Cypher tab displayed.
Either enter a Cypher query or select a saved query using the drop down arrow.
Click the Load Inner Relationship checkbox to include the relationships between the nodes pulled by a query.
Click the play icon to query the connected database.
The data appear in the graph space as nodes and their connecting edges.
Click the + (plus) icon to save a new query or to save one that you've edited.
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:
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.
Click Refresh Property to make sure all the properties in the database are listed.
Select properties you want to index. You can either
Click the All Category Properties checkbox to select all properties.
Click checkboxes to index selected properties.
Click Submit Index Task to index the database search terms.
A message displays indicating that the indexing task was successful.
Click the X at the upper right to close the dialog.
To pull data using full-text keyword search:
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.
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.
Click a list item to add the node to the graph space.
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.
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:
Click the Project panel icon and Category tab.
Click one of the Category items to select it.
Click Pull to pull 25 nodes associated with that category, and any edges that connect the nodes.
For added samples, click again, as many times as you want.
To pull data by Relationship:
Click the Project panel icon and Relationship tab.
Click one of the Relationship items to select it.
Click Pull to pull 25 edges associated with that relationship, the connected nodes, and all the other edges connected to those nodes.
For added samples, click again, as many times as you want.
Pull data using Expand
The Expand icon in the context toolbar menu lets you pull additional data which is connected to a selected node or group of nodes in the project the graph space.
To pull data using Expand:
Select one or more nodes in the graph space, then click the Expand icon to display the Expand with relationships dialog.
Click the checkbox next to a relationship name to pull nodes and edges connected by that relationship.
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.
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 repeatedly.
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 expanded.