Skip to content
Developer Edition runs on one host and does not require a product license file. Need multi-host deployment or performance testing at scale? Explore Enterprise Edition

OrAgg

An OrAgg aggregator value variable (OrAgg) maintains the result of logical OR operation on all inputs of the boolean type.

Declaration syntax

or_agg_declaration
NODE VALUE aggregator_value_variable OrAgg = value_expression

or_agg_declaration ::=
    'NODE'? 'VALUE' aggregator_value_variable 'OrAgg' '=' value_expression

For information about the parameters in the declaration syntax, see Parameters.

Initial value

As indicated in the declaration syntax, an initial value is required during declaration.

Input type and supported operations

The input type must be boolean.

Both assignment and aggregation operations are supported:

  • Assignment operation (=): This operation resets the value of the aggregate value variable. For example, SET or_agg = true clears the value held by the aggregate value variable or_agg and sets it to true. At this point, the result is true.
  • Aggregation operation (+=): This operation performs the logical OR operation on the value of the aggregate value variable and the input value, and updates the aggregate value variable with the result. For example, if or_agg has a value of true, executing SET @or_agg += false changes the value to true (because true OR false is true).

Return type

OrAgg -> BOOLEAN

The return type is always BOOLEAN.

Examples

The following examples are based on the temporary graph #movie_temporary_graph created in CREATE TEMPORARY GRAPH.

Global OrAgg aggregator value variables

'''
USE #movie_temporary_graph {
  VALUE global_or OrAgg = true

  // Aggregation: true OR true -> result remains true
  SET @global_or += true

  // Aggregation: true OR false -> result remains true
  SET @global_or += false

  // Aggregation: false OR true -> result remains true 
  SET @global_or += true

  LOG_INFO("@global_or: ", @global_or)

  // Assignment: reset variable directly to false
  SET @global_or = false

  LOG_INFO("@global_or: ", @global_or)
}
'''

Return:

Log:
2025-08-22T03:10:51.651099 INFO  - @global_or: true
2025-08-22T03:10:51.651645 INFO  - @global_or: false

Node-attached OrAgg aggregator value variables

'''
USE #movie_temporary_graph {
  NODE VALUE node_or OrAgg = false

  MATCH (a@User WHERE a.id in [3,4])-[]->(b@Movie)
  PER PATH {
    // For each user, perform logical OR with condition (b.id > 100)
    // The aggregator becomes true if any connected movie has id > 100
    SET a.@node_or += (b.id > 100)
  }
  PER NODE (a) {
    LOG_INFO("a.id: ",a.id, " a.@node_or: ",a.@node_or)
  }
}
'''

Return:

Log:
2025-08-22T03:32:20.042216 INFO  - a.id: 4 a.@node_or: true
2025-08-22T03:32:20.042216 INFO  - a.id: 3 a.@node_or: true