Welcome to our tutorial on how to use GraphXR Visual Query Builder!

In this Session…

  • Building Cypher Queries with Visual Query Builder


Slide

Text

2

Visual Query Builder is … a GraphXR Extension to create Cypher queries on a Neo4j database using drag-and-drop, no-code visual elements. 

3

Cypher is an open source query language introduced by Neo4j and used by many graph databases. Cypher enables pattern matching in graph data to:

  • Query for and return results as nodes and edges, tables, or lists. 

  • Load and transform data in a database.

  • Manage key database functions.

Visual Query Builder is focused on returning graph data to a GraphXR project as nodes and connected edges.

4

Anatomy of a basic Cypher query:

  • At least one MATCH statement to specify a graph pattern
    (and optionally specify property values):

    MATCH (n:Category)-[r:Relationship]-(m:Category)

  • Optional  WHERE statement to specify property values
    for the Categories and/or Relationships in the pattern.

    WHERE n.property value AND m.property value AND... etc.

  • A RETURN statement specifying the data to be returned.

    RETURN * LIMIT 100 

5

Cypher is powerful and versatile, but not everyone has the time to master it. That’s why Visual Query Builder provides:

  • Drag-and-drop, no-code query writing. 

  • Fast import to GraphXR.

  • Valid query formation that can help you learn Cypher faster.

6

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. 

7

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. 

8

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.

9

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.

10

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.

11

The query returns a default Limit of 25. We’ll increase that value in the text box.

12

Now we click the run arrow to query the database. Nodes are returned for Users whose screen_name property value includes the string “Joe”.

13

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.

14

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.

15

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

16

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.

17

On the Cypher Query block we increase the Limit, then click the run arrow. 

18

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). 

19

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.

20

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.

21

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.

22

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.

IMPORTANT! Opening a separate window using the Airplane icon clears a query. To avoid losing a query you’re building:

  • Open the separate window before you begin building a query

  • Export the query before returning to the docked workspace. 

23

We can also build loop patterns to explore retweets cycled among influential bot-like users, for example, over a two month period. 

24

Again, once it’s  built, we simply click the run arrow in the Cypher Query block.

25

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.

26

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).

27

We can use Visual Query Builder to sketch a query, then copy it to the GraphXR Query->Cypher tab for further editing. 

28

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. 

29

Thanks!

Next Steps…