如何在drools中跟踪多个匹配项
我有一条规则,可以对与我的产品代码匹配的产品触发多次。如何获得所有匹配的产品?我知道我可以使用全局和集合,但还有其他方法吗如何在drools中跟踪多个匹配项,drools,rules,rule-engine,Drools,Rules,Rule Engine,我有一条规则,可以对与我的产品代码匹配的产品触发多次。如何获得所有匹配的产品?我知道我可以使用全局和集合,但还有其他方法吗 global Set set rule "match multiple products" when $prod: Product(code=='PRD-MERCH') from productList then System.out.println('Matched Products'); set.add($prod); end 首先,让我告诉您,
global Set set
rule "match multiple products"
when $prod: Product(code=='PRD-MERCH') from productList
then
System.out.println('Matched Products');
set.add($prod);
end
首先,让我告诉您,您正在使用的productList中的
看起来已经可疑了。productList
是全球性的吗
现在,回到您的问题,如果您对所有匹配的产品
事实感兴趣,您可以使用收集
模式:
rule "match multiple products"
when
$prods: List(size > 0) from collect (
Product(code=='PRD-MERCH') from productList
)
then
System.out.println("Matched Products"+ $prods);
end
希望能有所帮助,谢谢你。是的productList是一个全球性的