Retrieving the compact result set
Appending the flag--compact to any query issued to the GRAPH.QUERY endpoint will cause the server to issue results in the compact format. Because we don’t store connection-specific configurations, all queries should be issued with this flag.
Formatting differences in the compact result set
Certain values are emitted as integer IDs rather than strings:- Node labels
- Relationship types
- Property keys
COLUMN_SCALAR. This enum is retained for backwards compatibility, and may be ignored by the client unless versions older than v2.1.0 must be supported.
ValueType indicates the data type (such as Node, integer, or string) of each returned value. Each value is emitted as a 2-array, with this enum in the first position and the actual value in the second. Each property on a graph entity also has a scalar as its value, so this construction is nested in each value of the properties array when a column contains a node or relationship.
Decoding the result set
Given the graph created by the query:redis-cli, which adds such visual cues as array indexing and indentation, as well as type hints like (integer). The actual data transmitted is formatted using the RESP protocol. All of the current FalkorDB clients rely upon a stable Redis client in the same language (such as redis-rb for Ruby) which handles RESP decoding.
Top-level array results
The result set above had 3 members in its top-level array:RETURN clause will have these 3 members. Queries that don’t return results have only one member in the outermost array, the query statistics:
Reading the header row
Our sample queryMATCH (a)-[e]->(b) RETURN a, e, b.name generated the header:
COLUMN_SCALAR. This element is retained for backwards compatibility, and may be ignored by the client unless FalkorDB versions older than v2.1.0 must be supported.
Reading result rows
The entity representations in this section will closely resemble those found in Result Set Graph Entities. Our query produced one row of results with 3 columns (as described by the header):ValueType, value].
It is the client’s responsibility to store the ValueType enum. FalkorDB guarantees that this enum may be extended in the future, but the existing values will not be altered.
The ValueType for the first entry is VALUE_NODE. The node representation contains 3 top-level elements:
- The node’s internal ID.
- An array of all label IDs associated with the node (nodes can have zero or more labels).
- An array of all properties the node contains. Properties are represented as 3-arrays - [property key ID,
ValueType, value].
ValueType for the second entry is VALUE_EDGE. The edge representation differs from the node representation in two respects:
- Each relation has exactly one type, rather than the 0+ labels a node may have.
- A relation is emitted with the IDs of its source and destination nodes.
- The relation’s internal ID.
- The relationship type ID.
- The source node’s internal ID.
- The destination node’s internal ID.
- The key-value pairs of all properties the relation possesses.
ValueType for the third entry is VALUE_STRING, and the other element in the array is the actual value, “Apple”.
Reading statistics
The final top-level member of the GRAPH.QUERY reply is the execution statistics. This element is identical between the compact and standard response formats. The statistics always include query execution time, while any combination of the other elements may be included depending on how the graph was modified.- “Labels added: (integer)”
- “Labels removed: (integer)”
- “Nodes created: (integer)”
- “Nodes deleted: (integer)”
- “Properties set: (integer)”
- “Properties removed: (integer)”
- “Relationships created: (integer)”
- “Relationships deleted: (integer)”
- “Indices created: (integer)”
- “Indices deleted: (integer)”
- “Query internal execution time: (float) milliseconds”
Procedure Calls
Property keys, node labels, and relationship types are all returned as IDs rather than strings in the compact format. For each of these 3 string-ID mappings, IDs start at 0 and increase monotonically. As such, the client should store a string array for each of these 3 mappings, and print the appropriate string for the user by checking an array at position ID. If an ID greater than the array length is encountered, the local array should be updated with a procedure call. These calls are described generally in the Procedures documentation. To retrieve each full mapping, the appropriate calls are:db.labels()
db.relationshipTypes()
db.propertyKeys()
Reference clients
All the logic described in this document has been implemented in most of the clients listed in Client Libraries. Among these, the official FalkorDB clients for Python, Node.js, and Java are currently the most sophisticated.Frequently Asked Questions
What is the compact result set format and why should I use it?
What is the compact result set format and why should I use it?
The compact format returns node labels, relationship types, and property keys as integer IDs instead of strings. This reduces data transfer overhead and improves performance. Enable it by appending
--compact to GRAPH.QUERY calls.How do I resolve integer IDs back to their string names?
How do I resolve integer IDs back to their string names?
Use the procedure calls
db.labels(), db.relationshipTypes(), and db.propertyKeys() to retrieve string-ID mappings. Clients should cache these locally and only refresh when encountering an unknown ID.What is the ValueType enum used for in compact results?
What is the ValueType enum used for in compact results?
The ValueType enum indicates the data type of each returned value (e.g., node, edge, integer, string). Each value in compact results is emitted as a 2-array:
[ValueType, value]. This enum may be extended in future versions but existing values will not change.Do I need to build a Redis protocol parser for my client?
Do I need to build a Redis protocol parser for my client?
No. FalkorDB clients should rely on an existing stable Redis client library in the same language (e.g., redis-py for Python, ioredis for Node.js) that handles RESP protocol decoding. Your client only needs to interpret the FalkorDB-specific result structure.
What happens when a query has no RETURN clause?
What happens when a query has no RETURN clause?
Queries without a RETURN clause produce only one top-level array element containing execution statistics (nodes created, relationships created, execution time, etc.), rather than the usual three elements (header, results, statistics).