redisgraph v0.1.0 RedisGraph.QueryResult View Source

A QueryResult containing returned fields and query metadata.

The resulting struct contains the result set header and records, statistics about the query executed, and referential lists of entity identifiers, specifically labels, property keys, and relationship types.

The labels refer to the label attribute of either Node entities in the graph, The property keys are the keys found in any Node or Edge property maps. The relationship types are the relation attributes of Edge entities in the graph.

Example

# Create a query to fetch some data
query = "MATCH (p:person)-[v:visited]->(c:country) RETURN p.name, p.age, v.purpose, c.name"

# Execute the query
{:ok, query_result} = RedisGraph.query(conn, graph.name, query)

# Show the resulting statistics
IO.inspect(query_result.statistics)

# Pretty print the results using the Scribe lib
IO.puts(QueryResult.pretty_print(query_result))

which gives the following results:

# Query result statistics
%{
  "Labels added" => nil,
  "Nodes created" => nil,
  "Nodes deleted" => nil,
  "Properties set" => nil,
  "Query internal execution time" => "0.228669",
  "Relationships created" => nil,
  "Relationships deleted" => nil
}

# Pretty printed output
+----------------+-------------+-----------------+--------------+
| "p.name"       | "p.age"     | "v.purpose"     | "c.name"     |
+----------------+-------------+-----------------+--------------+
| "John Doe"     | 33          | nil             | "Japan"      |
+----------------+-------------+-----------------+--------------+

Link to this section Summary

Functions

Return a boolean indicating emptiness of a QueryResult.

Get the labels added quantity from a QueryResult.

Create a new QueryResult from a map.

Get the nodes created quantity from a QueryResult.

Get the nodes deleted quantity from a QueryResult.

Pretty print a QueryResult to a tabular string using Scribe.

Get the properties set quantity from a QueryResult.

Get the query internal execution time (ms) from a QueryResult.

Get the relationships created quantity from a QueryResult.

Get the relationships deleted quantity from a QueryResult.

Transform a QueryResult into a list of maps as records.

Link to this section Types

Link to this type

t()

View Source
t() :: %RedisGraph.QueryResult{
  conn: term(),
  graph_name: term(),
  header: [String.t()],
  labels: term(),
  property_keys: term(),
  raw_result_set: [any()] | String.t(),
  relationship_types: term(),
  result_set: [[any()]],
  statistics: %{required(String.t()) => String.t()}
}

Link to this section Functions

Link to this function

is_empty(query_result)

View Source
is_empty(t()) :: boolean()

Return a boolean indicating emptiness of a QueryResult.

Link to this function

labels_added(query_result)

View Source
labels_added(t()) :: String.t()

Get the labels added quantity from a QueryResult.

Create a new QueryResult from a map.

Pass a map with a connection, graph name, and raw redisgraph result. The raw result is the output of the function Redix.command/2. This function is invoked by the RedisGraph.command/2 function.

The functions RedisGraph.commit/2, RedisGraph.query/3, RedisGraph.delete/2, and RedisGraph.merge/3 will also return a new RedisGraph.QueryResult.

Link to this function

nodes_created(query_result)

View Source
nodes_created(t()) :: String.t()

Get the nodes created quantity from a QueryResult.

Link to this function

nodes_deleted(query_result)

View Source
nodes_deleted(t()) :: String.t()

Get the nodes deleted quantity from a QueryResult.

Link to this function

pretty_print(query_result)

View Source
pretty_print(t()) :: String.t()

Pretty print a QueryResult to a tabular string using Scribe.

Link to this function

properties_set(query_result)

View Source
properties_set(t()) :: String.t()

Get the properties set quantity from a QueryResult.

Link to this function

query_internal_execution_time(query_result)

View Source
query_internal_execution_time(t()) :: String.t()

Get the query internal execution time (ms) from a QueryResult.

Link to this function

relationships_created(query_result)

View Source
relationships_created(t()) :: String.t()

Get the relationships created quantity from a QueryResult.

Link to this function

relationships_deleted(query_result)

View Source
relationships_deleted(t()) :: String.t()

Get the relationships deleted quantity from a QueryResult.

Link to this function

results_to_maps(query_result)

View Source
results_to_maps(t()) :: [map()]

Transform a QueryResult into a list of maps as records.