Logical Operators

The logical operators in CSDL are:

  • AND
  • OR
  • NOT

A AND B succeeds if both A and B succeed.

A OR B succeeds if at least one of them succeed.

For completeness, we include the truth tables.

Examples

1.  Filter for content that mentions Apple and includes the word "evangelist" in the title:

interaction.content contains "apple"
AND interaction.title contains "evangelist"

2.  Filter for content that mentions "Packard" but does not mention "Hewlett".

interaction.content contains "Packard"
AND NOT interaction.content contains "Hewlett"

3.  Filter for a 2-percent sample of interactions that refer to coffee or tea.

interaction.content contains_any "coffee, tea"
AND interaction.sample < 2

Precendence

There is no built-in operator precedence. Use parentheses to specify the precedence you require.

4.  Filter for posts that mention both "red" and "green" or that mention "blue":

(interaction.content contains "red" AND interaction.content contains "green")
OR interaction.content contains "blue"

5.  Filter for posts that mention "red" and also mention both "green" or "blue":

interaction.content contains "red" AND (interaction.content contains "green"
OR interaction.content contains "blue")

Limits

A maximum of 1000 conditions can be combined in a filter using AND or OR operators. You will receive the following error message if your filter contains more than this number.

An error occurred: "maximum recursion depth of 1000 has been reached"