Combined AND/OR Filters

Overview

Integration Manager filters support nested <and>, <or>, and <not> blocks to build complex boolean logic. You can combine multiple criteria with different logical operators to express sophisticated data selection rules.

Complete XML Examples

Multiple Criteria with AND

All criteria must be true:

XML
<filters>
    <filter id="activeExpensiveProducts">
        <and>
            <criterion fieldName="attribute1" operator="equals" value="ACTIVE"/>
            <criterion fieldName="attribute2" operator="greaterThan" value="100"/>
            <criterion fieldName="label" operator="notNull"/>
        </and>
    </filter>
</filters>

OR Logic

At least one criterion must be true:

XML
<filters>
    <filter id="priorityProducts">
        <or>
            <criterion fieldName="sku" operator="startsWith" value="PREMIUM-"/>
            <criterion fieldName="sku" operator="startsWith" value="VIP-"/>
            <criterion fieldName="attribute3" operator="equals" value="HIGH_PRIORITY"/>
        </or>
    </filter>
</filters>

Nested AND inside OR

"Products that are either (active AND expensive) OR (flagged as priority)":

XML
<filters>
    <filter id="complexSelectionFilter">
        <or>
            <and>
                <criterion fieldName="attribute1" operator="equals" value="ACTIVE"/>
                <criterion fieldName="attribute2" operator="greaterThan" value="100"/>
            </and>
            <and>
                <criterion fieldName="attribute3" operator="equals" value="HIGH_PRIORITY"/>
            </and>
        </or>
    </filter>
</filters>

AND with NOT Block

The <not> block negates a group of conditions. "Products that contain 'Test' but do NOT match any of the excluded attribute combinations":

XML
<filters>
    <filter id="complexFilterWithExclusions">
        <and>
            <criterion fieldName="attribute17" operator="iContains" value="Test"/>
            <not>
                <and>
                    <criterion fieldName="attribute14" operator="equals" value="90"/>
                    <criterion fieldName="attribute2" operator="equals" value="0"/>
                </and>
                <and>
                    <criterion fieldName="attribute14" operator="equals" value="95"/>
                    <criterion fieldName="attribute2" operator="equals" value="0"/>
                </and>
                <and>
                    <criterion fieldName="attribute14" operator="equals" value="96"/>
                    <criterion fieldName="attribute2" operator="equals" value="0"/>
                </and>
            </not>
            <criterion fieldName="attribute21" operator="equals" value="0"/>
            <criterion fieldName="attribute10" operator="equals" value="0"/>
            <criterion fieldName="attribute14" operator="notEqual" value="88"/>
        </and>
    </filter>
</filters>

OR at Top Level with AND Subgroups

"Match customers from region EU with high volume, OR customers from region US with premium tier":

XML
<filters>
    <filter id="targetCustomersFilter">
        <or>
            <and>
                <criterion fieldName="attribute1" operator="equals" value="EU"/>
                <criterion fieldName="attribute2" operator="greaterThan" value="10000"/>
            </and>
            <and>
                <criterion fieldName="attribute1" operator="equals" value="US"/>
                <criterion fieldName="attribute3" operator="equals" value="PREMIUM"/>
            </and>
        </or>
    </filter>
</filters>

How It Works

  1. <and> -- all child criteria/blocks must evaluate to true (logical conjunction).

  2. <or> -- at least one child criterion/block must evaluate to true (logical disjunction).

  3. <not> -- negates the enclosed group of criteria. The <not> block contains one or more <and> groups; records matching ANY of those groups are excluded.

  4. Nesting is recursive: you can place <and> inside <or>, <or> inside <and>, and <not> inside either.

  5. The top-level block inside <filter> is typically <and> or <or>.

Common Pitfalls

  • <not> structure: The <not> block contains <and> sub-blocks, not bare <criterion> elements. Each <and> inside <not> represents one exclusion pattern.

  • Deep nesting performance: Highly nested filter trees can generate complex server-side queries. Keep nesting to 2-3 levels when possible.

  • OR vs multiple filters: Sometimes it is clearer to define separate filters for separate fetch operations rather than a single complex OR filter.

  • Empty blocks: An empty <and/> matches everything; an empty <or/> matches nothing. Be careful with programmatically generated filters.

  • Operator precedence: There is no implicit precedence -- the structure of the XML tree determines evaluation order. Always use explicit nesting.