View Source RedisGraph.QueryResult (ex_redisgraph v0.1.0)

A QueryResult is responsible for processing the data that was returned by RedisGraph.

https://redis.io/docs/stack/graph/design/result_structure/

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 labels attribute in Node entities in the graph, The property keys are the keys found in any Node or Relationship property maps. The relationship types are the type attributes of Relationship entities in the graph.

example

Example

alias RedisGraph.Graph

# Create a connection using Redix
{:ok, conn} = Redix.start_link("redis://localhost:6379")

# Create a graph
graph = Graph.new(%{name: "imdb"})

# Create queries and send them to RedisGraph
create_query = "CREATE (a:actor {name: 'Hugh Jackman'})-[:act]->(m:movie {title:'Wolverine'}) RETURN a"
{:ok, _query_result} = RedisGraph.query(conn, graph.name, create_query)

match_query = "MATCH (a:actor {name: 'Hugh Jackman'})-[:act]->(m:movie {title:'Wolverine'}) RETURN a"
{:ok, query_result} = RedisGraph.query(conn, graph.name, match_query)

# Show the resulting statistics
IO.inspect(query_result.statistics)
 # 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
}

Link to this section Summary

Functions

Get the indices created quantity from a QueryResult.

Get the indices deleted quantity from a QueryResult.

Return a boolean indicating emptiness of a QueryResult.

Get the labels added quantity from a QueryResult.

Get the labels removed 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.

Get the properties removed quantity from a QueryResult.

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 the results_set from QueryResult into a list of maps as records.

Link to this section Types

@type t() :: %RedisGraph.QueryResult{
  conn: pid(),
  graph_name: String.t(),
  header: [atom()],
  labels: %{required(number()) => String.t()},
  property_keys: %{required(number()) => String.t()},
  raw_result_set: [any()] | String.t(),
  relationship_types: %{required(number()) => String.t()},
  result_set: [[any()]],
  statistics: %{required(String.t()) => String.t()}
}

Link to this section Functions

Link to this function

indices_created(query_result)

View Source
@spec indices_created(t()) :: String.t()

Get the indices created quantity from a QueryResult.

Link to this function

indices_deleted(query_result)

View Source
@spec indices_deleted(t()) :: String.t()

Get the indices deleted quantity from a QueryResult.

@spec is_empty(t()) :: boolean()

Return a boolean indicating emptiness of a QueryResult.

Link to this function

labels_added(query_result)

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

Get the labels added quantity from a QueryResult.

Link to this function

labels_removed(query_result)

View Source
@spec labels_removed(t()) :: String.t()

Get the labels removed quantity from a QueryResult.

@spec new(map()) :: t()

Create a new QueryResult from a map.

Pass a map with a connection, graph name, and raw RedisGraph result/response. 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.query/3, RedisGraph.delete/2 and RedisGraph.call_procedure/5 will also return a new RedisGraph.QueryResult.

Link to this function

nodes_created(query_result)

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

Get the nodes created quantity from a QueryResult.

Link to this function

nodes_deleted(query_result)

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

Get the nodes deleted quantity from a QueryResult.

Link to this function

properties_removed(query_result)

View Source
@spec properties_removed(t()) :: String.t()

Get the properties removed quantity from a QueryResult.

Link to this function

properties_set(query_result)

View Source
@spec 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
@spec 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
@spec relationships_created(t()) :: String.t()

Get the relationships created quantity from a QueryResult.

Link to this function

relationships_deleted(query_result)

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

Get the relationships deleted quantity from a QueryResult.

Link to this function

results_to_maps(query_result)

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

Transform the results_set from QueryResult into a list of maps as records.