Source: https://dev-docs.nebula-graph.io/v5.3.2/database-gql-reference/variable-definition/agg/or_agg/ Documentation version: v5.3.2 # OrAgg An OrAgg aggregator value variable (`OrAgg`) maintains the result of logical `OR` operation on all inputs of the boolean type. ## Declaration syntax diagramsource or_agg_declaration ```` or_agg_declaration ::= 'NODE'? 'VALUE' aggregator_value_variable 'OrAgg' '=' value_expression ```` For information about the parameters in the declaration syntax, see [Parameters](https://dev-docs.nebula-graph.io/v5.3.2/database-gql-reference/variable-definition/agg/#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](https://dev-docs.nebula-graph.io/v5.3.2/database-gql-reference/set/) 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](https://dev-docs.nebula-graph.io/v5.3.2/database-gql-reference/ddl/graph-projection/create/). ### 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 ````