Chapter 6. Tutorial

6.2. Search phrases for Advanced Queries

As mentioned in Section 4.5.2, “Search phrase”, a Search phrase allows you to save a pre-defined graph query. Search phrases are defined in the Perspective designer.

6.2.1. Static Search phrase

static search phrase

In this example using the Northwind graph, a static Search phrase has been saved with a Cypher query that spans multiple nodes and relationships. The first box titled Search phrase specifies the phrase that the user will type in partially or fully. The description appears underneath all the Search phrase matches displayed to the user.

Bloom will match any part of the Search phrase field in a case-insensitive fashion. For example, typing in germ or ORDER or SeaFoo will all show a match for Germans ordering Seafood.

6.2.2. Parameters in Search phrases

parameterized search phrase

Parameters can be used in Search phrases to make them dynamic. In this example using the Northwind graph, there are 2 parameters (indicated with $ sign in front) added to the Search phrase. These allow for further user input to determine which query should be run. There are three options available for suggestions to these parameters:

  • No suggestions - If selected, the suggestions list will not show when using the Search phrase.
  • Label-key - Allows picking label:key pair for the suggestions list.
  • Cypher query - Custom written Cypher query for the suggestions list.

6.2.2.1. Parameter data types

Starting in version 1.2, the data type for every parameter must be specified. At this time, Bloom supports string, integer, float and boolean data types. User input for a parameter gets converted to the data type specified for it.

If you want to setup parameters for other data types supported in Cypher, you can use a combination of string, integer, float and boolean inputs to build other data types for Cypher. Please see Cypher manual, Values and types for more information on data types.

A couple of scenarios are described below, but there are a number of others that you may come across.

  • Temporal (date or time) type: When you have temporal properties, you can use date, time or datetime Cypher functions along with a string parameter. For example:

    MATCH (n:Employee) where n.startDate = date($inDate)
    return n

    where $inDate would be a string input like 2019-05-23.

  • Spatial type: For spatial properties, you can use point or distance Cypher functions along with float parameters in a Search phrase. For example:

    MATCH (n:Store) where n.location = point({latitude:$lat, longitude:$long})
    return n

    where $lat and $long would have float inputs like 37.55 and -122.31.

6.2.2.2. Chaining of parameters

The user-input for one parameter can be used to filter the list of suggestions provided for a subsequent parameter. This is referred to as parameter chaining. For example, consider the Search phrase used above with multiple parameters, Customers from $country ordering $category. In this case, perhaps you want to restrict the list of category suggestions based on the country the user picked, parameter chaining will help you achieve this. To use it, the list of category suggestions will need to be constructed using a Cypher query that uses the $country parameter to filter categories. See image below for an example of what this could look like.

parameter chaining

6.2.3. Search phrases caveats

  • It is recommended that Search phrases either return a path or a set of nodes.

    Returning only relationships may cause unexpected behaviour in addition to no graph visualization changes.

    For example, the following query:

    MATCH ()-[r:CONNECTED_TO]->() RETURN r

    Should be refactored to:

    MATCH p = ()-[r:CONNECTED_TO]->() RETURN p
  • Furthermore, be aware that it is possible to modify data with a Search phrase as any valid Cypher query can be used. It is not recommended to use Search phrase for this goal as an end-user might not be aware of the consequences of running a Search phrase that includes WRITE transactions.

6.4. Export data from Bloom

Bloom allows you to share your insights. Once you have found an interesting scene, you can extract your results as two CSV files, one representing the nodes and the other the relationships present in the current scene. This way, you may also use your results in applications other than Bloom.

In this example, you want a list of all German customers that order products from the Seafood category to pass on to a hypothetical marketing department for a promotion. Using the Germans ordering Seafood Search phrase from above, the scene displays the customers you are looking for. The context menu allows you to export your current scene as CSV. You can share the relevant file, or both, with marketing. If you need to edit the scene after using the Search phrase, for example remove a customer that should be exempt from the coming promotion, do so and export once you are satisfied. Only the nodes and relationships shown in the current scene will be exported.

export as csv

6.6. Default actions and shortcuts

A summary of the actions and associated keyboard shortcuts are below.

Table 6.1. Neo4j Bloom Actions and their Keyboard Shortcuts
  Action Description Shortcut

icon magnifying glass

Inspect

Opens the detail view of a selected node, showing all its properties and labels

Mac: +I

Windows: Ctrl+I

icon pencil

Edit node

Allows editing of all the properties of the selected node at once

Mac: ++E

Windows: Ctrl+Alt+E

icon invert

Invert Selection

Inverts the current selection

Mac: ++A

Windows: Ctrl+Alt+A

icon fit selection

Fit to selection

Zooms in and centers the selection on the canvas

Mac: +F

Windows: Ctrl+F

icon expand reveal

Expand

Expands all the neighbours of the selected nodes)

Mac: +E

Windows: Ctrl+E

icon expand reveal

Reveal

List/Detail view specific action. Reveals all the selected nodes or relationships on the canvas

 

icon path

Path

Shows the shortest path between two selected nodes

 

icon dismiss

Dismiss

Hides all selected nodes and relationships

Mac: +H

Windows: Ctrl+H

icon dismiss

Dismiss other nodes

Hides everything that is not selected

Mac: ++H

Windows: Ctrl++H

icon add

Create relationship

Allows the creation of relationship between two selected nodes. The direction is set in the sequence in which the two nodes are clicked

 

icon add

Create node

Allows the creation of a node in a specified category. The newly created node will inherit all the labels that category has

 

icon duplicate

Duplicate

Duplicates a selected node with all the properties it has. The newly duplicated node is always selected and has no relationships to other nodes

Mac: +D

Windows: Ctrl+D

icon clear

Clear Scene

Clears the whole scene and collapses the list view

 

icon undo

Undo

   

icon redo

Redo

   

icon jumpto

Jump to node/ relationship

Zooms in and centers the desired node or relationship on the canvas

 
 

Select All

Selects all properties and relationships on the canvas

Mac: +A

Windows: Ctrl+A

 

Zoom In

 

Mac: ++

 

Zoom Out

 

Mac: +-