In this Session…

Before you begin…

  • Using Cypher to query a Neo4j database.

  • Pulling data using Expand.

  • Pulling data by category.

  • Pulling data using keyword search.

To follow along:

  • Log in to GraphXR and open the Game of Thrones Demo Project.



How To GraphXR 13. Querying


Before You Begin…

Ideally, you’ll have worked through Module 12. Geospatial Mapping and Tagging. If you’re starting here, and you want to follow along, you’ll need to:

  • Log in to GraphXR.

We’ll use a demo project which connects GraphXR to data in a Neo4j graph database.  


We’ll open a demo project connected to a Neo4j graph database and pull its data into GraphXR in various ways. (If you are in a project space, click the Home button to exit and return to the Projects page.) Click Select Demo and choose the Game of Thrones demo.


Click the  arrow on the Game of Thrones demo to enter its graph space.


The demo project graph space will be blank as we have not yet queried in any data. To inspect categories and relationships defined for database connected to this demo project, you can click the Project panel.


Open the Query panel and Cypher tab. Let’s start by pulling data into GraphXR using a Cypher  query, which returns graph data that match patterns you specify.


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

A default example query is provided that will: 

MATCH any pattern of nodes n and m connected by any relationship r and RETURN the first 100 found. This query will return a large amount of data, so it’s prudent to set a LIMIT


You can also set a limit by entering Maximum return records allowed. This will override a larger limit set in the LIMIT qualifier. Now let’s create our own, more specific query.


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

Here we query for the pattern (Character) – [belongs_to] – (House). 

We set variables c, r, and h that we can use in further query specifications instead of the full category or relationship name. For this query we’ll set the limit of 100 returns in Maximum return records allowed.


Now click the run arrow to the right of the query to pull in data. The query returned (Character) - [belongs_to] – (House) patterns that included 98 total nodes: 85 Character and 13 House nodes.


Click the save icon to save your query. The display icon shows a dropdown menu of saved queries. For more information about using Cypher, comprehensive and free learning resources for developers are available through Neo4j.


Now that data are available in the graph space, you can use Expand to pull additional data connected to selected nodes. Select one or more nodes and click Expand icon.


In the Expand with relationships dialog, choose relationships, their direction, and enter a Limit. Then click Expand. You can progressively pull a maximum of 2,000 results at a time.


We now see Scene nodes associated with the selected Character node. Expand enables an “inside out” workflow: you can start with a single point of interest and pull in nodes with the relationships that are most relevant to your investigation.


Data for a selected Category or Relationship can be pulled from the database 25 nodes at a time. Go to the Project panel and the Category  tab. Select the Episode category and click Pull


The nodes are pulled from the database, along with relationships that may exist between the pulled nodes and nodes already in the graph. Now click the Relationship tab.


Select the scene_in_episode relationship and click Pull. Edges will only be pulled if nodes to connect them to are present in the graph space.


Since this demo database is configured for keyword search, you can enter search terms in the Search Bar to return matching nodes. Check that the search from database icon is displayed and enter a search term (Episode). 


Click the plus (+) icon to pull all results or click a single line to pull just one node.  Next, in Module 14. Data Mapping , we’ll load CSV data and map it into a graph format. 

Next Steps…