Corticon Studio: Rule Modeling Guide : Filters and preconditions : Using collection operators in a filter : Multiple filters on collections

Multiple filters on collections
Let's construct a slightly more complicated example by adding a third conditional expression to our rule.
Figure 188. Rulesheet with 2 Conditions
Figure 189. Rulesheet with 2 Filters
Once again, our Rulesheets differ only in the location of a Conditional expression. In the first rulesheet above, the gender test is modeled in the second Conditional row, whereas in the other rulesheet (Rulesheet with 2 Filters), it's implemented in the second Filter row. Does this difference have an impact on rule execution? Let's build a Ruletest and use it to test the Rulesheet in Rulesheet with 2 Conditions first.
Figure 190. Ruletest
As we see in this figure, the combination of a Condition that uses a collection operator (the size test) with another Condition that does not (the gender test) produces an interesting result. What appears to have happened is that, for a collection of more than 3 skydivers, all females in that group have been assigned a riskRating of 'high';. Step-by-step, here is what the Corticon Server did:
1. The Filter screened the collection of Persons (represented by the alias person) for skydivers.
2. If there are more than 3 surviving elements in person (i.e., skydivers), then all females in the filtered collection are assigned a riskRating value of high. It may be helpful to think of the Corticon Server checking to make sure there are more than three surviving elements, then cycling through those whose gender is female, and assigning riskRating one element at a time.
Expressed as a plain-language rule statement, our Rulesheet implements the following rule statement:
It's important to note that Conditions do not have the same filtering effect on collections that Filter expressions do, and the order of Conditions in a rule has no effect whatsoever on rule execution.
Now that we understand the results in Ruletest, let's see what our second Rulesheet produces.
Figure 191. Ruletest
This time, no riskRating assignments were made to any element of collection person. Why? Because multiple Filters are logically AND'ed together, forming a compound filter. In order to survive the compound filter, elements of collection person must be both skydivers AND female. Elements that survive this compound filter pass through to the size test in the Condition/Action rule, where they are counted. If there are more than 3 remaining, then all surviving elements are assigned a riskRating value of high. Rephrased, our Rulesheet implements the following rule statement:
Just to confirm we understand how the Corticon Server is executing this Rulesheet, let's modify our Ruletest and rerun:
Figure 192. Ruletest with Risk Ratings
Ruletest with Risk Ratings now includes 4 female skydivers, so, if we understand our rules correctly, we expect all 4 to pass through the compound filter and then satisfy the size test in the Conditions. This should result in all 4 surviving elements receiving a riskRating of highRuletest with Risk Ratings confirms our understanding is correct.