Remember that "collect" is a simplified form of "accumulate". So when you can't achieve what you want with collect, first thing you should look for is accumulate.

$list : List() from accumulate(
        $foo : Foo( ) and not Bar( id == $ ),
        collectList( $foo ) )

   Please note that I changed your example making the constraint in Bar use "==" instead of "!=" because I think that is what you want. But if it is not, just use whatever expression you want.

   Also be aware that collect/accumulate are heavy CEs. Nesting multiple patterns inside accumulate is even heavier, so use it wisely.

   Hope it helps,

2009/8/18 techy <>

Please someone help me on this.

techy wrote:
> I would like to collect All Foo() for which there is no Bar() as given
> below.Please help me on this.
> Thanks.
> //psedo rule
> rule 'test'
> list : from collect( Foo(fooId: id) and not Bar(id !=fooId))
> then
> //do conseq
> end

View this message in context:
Sent from the drools - user mailing list archive at

rules-users mailing list

 Edson Tirelli
 JBoss Drools Core Development
 JBoss by Red Hat @