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

AndAgg

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

Declaration syntax

and_agg_declaration
NODE VALUE aggregator_value_variable AndAgg = value_expression

and_agg_declaration ::=
    'NODE'? 'VALUE' aggregator_value_variable 'AndAgg' '=' 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 @and_agg = true clears the value held by the aggregate value variable and_agg and sets it to true. At this point, the result is true.
  • Aggregation operation (+=): This operation performs the logical AND 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 and_agg has a value of true, executing SET @and_agg += false changes the value to false (because true AND false is false).

Return type

AndAgg -> 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 AndAgg aggregator value variables

'''
USE #movie_temporary_graph {
  VALUE global_and AndAgg = true

  // Aggregation: true AND true -> result remains true
  SET @global_and += true

  // Aggregation: true AND false -> result becomes false
  SET @global_and += false

  // Aggregation: false AND true -> result remains false 
  SET @global_and += true

  LOG_INFO("@global_and: ", @global_and)

  // Assignment: reset variable directly to true
  SET @global_and = true

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

Return:

Log:
2025-08-21T09:54:50.956839 INFO  - @global_and: false
2025-08-21T09:54:50.957806 INFO  - @global_and: true

Node-attached AndAgg aggregator value variables

'''
USE #movie_temporary_graph {
  NODE VALUE node_and AndAgg = true

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

Return:

Log:
2025-08-21T09:58:56.690844 INFO  - a.id: 4 a.@node_and: false
2025-08-21T09:58:56.690844 INFO  - a.id: 3 a.@node_and: true