Skip to main content

Explore query results

An openCypher query can return a variety of results. When the query returns a list of entities or relationships, they are displayed in the results list with one entity or relationship per row. Values returned by the query appear in columns in the order they are listed in the query return statement.

An openCypher query may return results that show which entities have a given relationship to another entity. In this case, the results table will show one row for each triple where a triple consists of the origin entity, the relationship, and the target entity. For example, a query such as MATCH (p:Person)-[r]->(e) RETURN p,r,e would return a results list in which each row in the results table represents a person, a relationship between that persona and another entity, and the target entity of the relationship. In this case, the results table would have a column for the person titled p, a column for the relationship titled r, and a title for the target entity titled e.

Results of a query that returns origin and destination entities and the relationship that connects them

If instead, the query returns specific properties of entities or relationships, the results list will display those values in each column. For example, a query such as MATCH (p:Person)-[:HasVehicle]->(v) RETURN p,v,v.year will return the display name of the Person entity in the p column, the display name of the Vehicle entity in the v column, and the value of the Vehicle entity's year property in the v.year column. If an entity doesn't have a value for a specific property that is returned by a query, you will see (NULL) as a representation of the fact that there is no value to show.

The example below illustrates a query that returns a Person entity in which the person participates in a HasVehicle relationship with the vehicle. The query also returns the acquisitionDate property of the HasVehicle relationship, and the make property of the Vehicle entity.

Results of a query that return a Person entity in which the person participates in a HasVehicle relationship with the vehicle and the a property of the vehicle entity.

Columns containing an entity Entity, relationship Relationship or provenance record will show the display name for the record along with its icon.

A third common type of query returns a path between one entity and another. A path contains all entities and relationships between the specified origin and destination entities. For example, a query such as MATCH path=(p:Person)-[r]->(e) RETURN path will return all of the paths to any entities connected to a Person entity by one relationship.

Result of a path query displays all records in the path in a single column in the result table.

Paths can include any number of entities and relationships. For example, a query such as MATCH path=(c:Company)-[r*2]-(v:Vehicle) RETURN path will return all paths between Company entities and Vehicle entities that are exactly two relationships away. Each path will contain the origin Company entity, each intermediary entity and relationship, and the destination Vehicle entity. By default, it will just display the origin entity and destination entity in the path and the total number of records in the path. Click the Expand Expand query rows to view the full path result.

Results of a path with multiple relationships between the origin and destination entities.

Paths can be returned as one element of a query result. For example, the same query can return the path and the name of the origin company and the year of the destination vehicle. MATCH path=(c:Company)-[r*2]-(v:Vehicle) RETURN path, c.name, v.year.

Result of a query that returns a path as well as properties of specific entities within that path.

All query results are displayed in the table view by default. In this view, you can select query results, and view the properties of any entity or relationship returned from the query.

  1. Click an entity Entity or a relationship Relationship in the results table to see it's properties.

  2. Optionally, use Add To Add To to add this record to another content item.

  3. Click the checkbox in the first column to add all of the entities and relationships in that row to your selection.

    The entities and relationships in this row will be highlighted. Any instances of those entities and relationships that appear in other result rows will also be highlighted. The total number of selected records is displayed at the bottom of the table.

    Records selected in the table are highlighted in each result they appear.

  4. Optionally:

    • Press Ctrl while clicking an entity Entity or relationship Relationship to add just that record from your selection.

    • Click the checkbox in the header of the first column of the table to select all records returned from the query.

  5. Click the checkbox in the first column to remove all of the entities and relationships in that row from your selection.

  6. Optionally:

    • Press Ctrl while clicking an entity Entity or relationship Relationship to remove just that record from your selection.

    • Uncheck the checkbox in the header of the first column to deselect all records returned from the query.

  7. Use the Add To in the query context toolbar to add your selected records to a link chart, map or data card.

  8. Use the Selection Manager to manage selected records across queries in the query view.

Preview the results in a map or link chart

You can also use the query results map preview and query results link chart preview to preview the results of your query in a different visualization. Any selections made in the table view will be reflected in the map preview and link chart preview. You can modify the selection from the map or link chart preview using the interactive selection tools.

  1. Click the Map view Map view in the results menu to see a preview of the spatial entities returned by your query.

    Map preview of query results shows any selections made in the table view.

  2. Optionally, modify the selection in the map using the interactive selection

  3. Click the Link Chart view Link chart view in the results menu to see a preview of your query results visualized in a link chart.

    Query results link chart preview shows any selections made in the table view.

  4. Optionally, modify the selection in the map using the interactive selection

  5. Click the Table view Table in the results menu to return to the results table.

  6. Use the Selection Manager to manage selected records across queries in the query view.

Preview query results with a chart

You can also use the charts view to visualize your query results in different ways. You can configure several types of charts that visualize characteristics and relationships from your query results. You can also choose how to aggregate the query results in your chart. You can select results in your chart and add them to a map or link chart. Chart configurations are not included in stored queries.

The following chart types are supported in Knowledge Studio:

Chart Description
Bar chart Bar charts group data by categories along the x-axis. Use a bar chart to summarize and compare categorical data.
Box plot Box plots display the distribution of one or more numeric attributes. Use a box plot to visualize and compare the distribution and central tendency of numeric values through their quartiles.
Heat chart Heat charts visualize data using a matrix of colored cells. Use a heat chart to visualizing correlations, density, or patterns between categorical variables.
Histogram Histograms visualize the distribution of a numeric attribute. Use a histogram to visualize the distribution of values in a numeric variable by grouping numbers into bins and measuring the frequency of those groups.

Configure a chart to summarize your query results.

  1. Click the Charts view in the results menu.

  2. Under Chart Settings select a Chart Aggregation method.

  3. Click the Chart type dropdown and select the type of chart to create.

  4. Configure the chart parameters.

  5. Click Apply.

    The chart appears in the chart view.

  6. Optionally, select results in your chart.

  7. In the context toolbar, click Add To , and click the appropriate option to add your chart selection to a map or link chart.

    • Under Add to new, click Map Map to create a map in the project.

    • Click Map from Template New map from template under Add to new and select the map to use as the template. Click Add.

    • Under Add to new, click Link Chart Link chart to create a link chart in the project.

    • Click Link Chart from template New link chart from template under Add to new and select the link chart to use as the template. Click Add.

    • Under Add to existing, click the name of an existing map or link chart.

    The selection is added to the map or link chart.

Work with chart aggregation

Chart aggregation settings allow you to configure how a chart will organize and preview your query results. It will also determine how selections made on your chart are reflected in the the table view. Chart aggregation methods are described below:

  • Table Rows—Uses the rows and columns from the query results table. When an entity or relationship is returned in a column, its properties can also be used for charting. Selections made in your chart will apply to the entire rows in the table view that are used in the chart selection. If entities and relationships are returned in a row that is selected, they will be selected wherever they appear in the table view.

  • Entities and Relationships—Uses only the unique entities and relationships from your query results, grouped by their type. Their properties become the fields available for charting. Selections made in your chart will apply only to the individual entity or relationship in the table view, disregarding the row or column they were returned in.

The chart aggregation method allows you create a visualization of query results in different ways without the need for a new query. For example, the openCypher query below finds supply chain paths connecting a specific Supplier to both Plants or other Suppliers one to four hops away using multiple relationship types. It then aggregates the cost of all Part entities along each path, and returns both the path and a total cost.

MATCH path=(supplier:Supplier)-[:supplies|:raw_supplies|:produces|:purchased_by*..4]-(facility)
WHERE (facility:Plant OR facility:Supplier)  and supplier.globalid IN $supplier
WITH nodes(path) AS allNodes, path, supplier, facility
UNWIND allNodes AS node 
WITH node, path, supplier, facility
WHERE node:Part 
WITH ROUND(SUM(node.COST) * 100) / 100.0 AS totalCost, path,  supplier, facility
RETURN supplier, facility, totalCost, path 

Using this query to visualize supplier roles in a bar chart presents different information--answering different questions--based on the chart aggregation method. Additionally, the selections made on the chart will change based on aggregation method. The below screenshots compare the results returned in the charts view:

The table rows aggregation method returns the number of different paths or networks that originate with a supplier of each role. If a supplier is the origin of many different paths, each path will be counted for that suppliers role. Selecting a bar will select all the entities and relationships in the table row where the origin supplier is of that tier, including any other parts, plants or suppliers in the path.

The chart results returned using Table Rows aggregation method.

By contrast the entities and relationship aggregation method returns the total number of distinct suppliers of each type returned anywhere in any of the paths, independent of the table rows returned in the query result. Selecting a bar will only select the individual suppliers of that role.

The chart results returned using Entities and Relationships aggregation method.

By using different aggregation methods, you can determine how entities and relationships are represented in the charts view to answer different questions.