Visual Query Builder
Welcome to our tutorial on how to use GraphXR Visual Query Builder!
In this Session…
Visual Query Builder is … a GraphXR Extension to create Cypher queries on a Neo4j database using drag-and-drop, no-code visual elements.
Cypher is an open source query language introduced by Neo4j and used by many graph databases. Cypher enables pattern matching in graph data to:
Visual Query Builder is focused on returning graph data to a GraphXR project as nodes and connected edges.
Anatomy of a basic Cypher query:
Cypher is powerful and versatile, but not everyone has the time to master it. That’s why Visual Query Builder provides:
We’ll show examples from a research project on social media and the 2020 US election. In the GraphXR project, we access Visual Query Builder from the Extensions dropdown, then click to add a Cypher Query block to the workspace.
We start with a simple query on a single category: Twitter Users with a screen_name like “Joe”. Click to add a Category block. Notice that as we build it, the query is displayed in the Cypher Query block.
We click the Settings icon on the Category block, and choose the User category. Next we click the screen_name property checkbox and click OK.
Our User block now includes the screen_name property. Then we click to add a Property block to set the screen_name values for the query.
In the Property block, we choose Like, and enter Joe in the text field below. Now we click its socket (the open circle at the upper right) and drag the line to the screen_name socket.
The query returns a default Limit of 25. We’ll increase that value in the text box.
Now we click the run arrow to query the database. Nodes are returned for Users whose screen_name property value includes the string “Joe”.
Next we’ll build a simple pattern with categories connected by a relationship. We’ll query for influential users who have retweeted to one another in a given month, and who are probably trolls or bots.
For this pattern we need two Category blocks set to User and with boto-prob and followers_count properties selected. And we need a Relationship block set to the RETWEETED_2020_09 relationship.
The query should be for a directional relationship, so we click the relationship settings icon, display Advanced options, choose Right from the Direction menu, and click OK.
We specify that the User followers_count greater than 20,000, and a boto_prob (likelihood that the user is a bot) greater than 0.90. So we need to add and connect two Property blocks for each User block in the pattern.
On the Cypher Query block we increase the Limit, then click the run arrow.
A branched pattern can easily be added to the previous query. We’ll query for our influential bot-like users where the first User has sent video with a Tweet: (User)-[send_tweet]-(Tweet)-[has_media]-(Media).
The branched query adds another MATCH statement for any Tweet sent by the first User that has attached Media with a type property like “video”. The query now returns those additional nodes and edges.
Before building more queries, we can save this one. Clicking the Export icon exports the query as a .JSON file. Now any GraphXR user can Import it.
We can click the Clear icon to clear the visual query from the workspace. We can also drag any single block to the Trash icon to delete it.
While building a query, we can click the split screen or full screen icons at any time to expand the workspace in the browser window. We can also open a separate window using the Airplane icon. The query you’re building now persists until you clear it.
We can also build loop patterns to explore retweets cycled among influential bot-like users, for example, over a two month period.
Again, once it’s built, we simply click the run arrow in the Cypher Query block.
We can also query for patterns of various lengths, i.e. the number of nodes connected via a specific relationship. Click the relationship Settings icon and Advanced option. Then use the Length drop down menu to set a length.
We can choose equal for a length from zero up to the entered value, greater than for a length greater than or equal to the entered value, or between for a range (e.g 3 - 5).
We can use Visual Query Builder to sketch a query, then copy it to the GraphXR Query->Cypher tab for further editing.
In the Query->Cypher tab, paste from the clipboard into the query text box. Now we can run, edit, and save it in your GraphXR project.