Boolean Expressions

There are three basic Boolean Operators: AND, OR and NOT. These are used to make your query more specific and are part of almost every query.

  • AND
    This is the default operator and thus doesn't need to be specified explicitly. You can, however, use an ampersand (&) to clarify the relation in your query.

    Example:
    A < B < C (same as A < B & < C)
    A is the parent of B AND the parent of C

  • OR
    This operator is used when you have multiple relationships and only one has to be satisfied. It is represented by the pipe-symbol (|). Press Alt Gr + <(Windows) or Option + 7(Mac) to type it.

    Example:
    A < B |< C
    A is the parent of B
    OR
    A is the parent of C

    Note that AND binds stronger than OR. So the expression A < B . C | . D would evaluate as:
    A is the parent of B AND immediately precedes C
    OR
    A immediately precedes D

    If you are looking for the query:
    A is the parent of B AND immediately precedes C
    OR
    A is the parent of B AND immediately precedes D

    you will need to use squared brackets ([ and ]):
    A < B [. C | . D]
    The left bracket ([) is put before the basic link and the right bracket (]) after the node name.

  • NOT
    Every relationship can be negated. For this you will need an exclamation mark (!). This operator is used to exclude certain results that you don’t want to find. See Basic approach in the Chapter Finding the correct query.

    Example:
    A < B !< C
    A is the parent of B and NOT the parent of C