Unable to Analyse Expression error for large rules

937 Views Asked by At

We are using Drools v6.3.4 - but tested that the same issue is happening in v7.3.0 as well. When we write a rule where the rule is 27000 characters long or more, we get "Unable to Analyse Expression" error

rule "StoreRule"

    when
        (s: Store.StoreItems(storeitemname in ("STORE0000001","STORE0000002"....really long list)))
    then
        System.out.println("Discount!");
end

We have a workaround which is to split the rule up like this -

rule "StoreRule"

    when
        (s: Store.StoreItems(storeitemname in (<List 1>))) ||
        (s: Store.StoreItems(storeitemname in (<List 2>))) ||....and so on
    then
        System.out.println("Discount!");
end

What is the underlying reason for the error we are getting with a single long list? Is there a better way to handle such rules other than the workaround specified above?

When we are having large rule , we are getting the following error.

enter image description here

1

There are 1 best solutions below

0
On

Make sure one storeitemname can't be part of other storeitemname

rule "StoreRule"

    when
        (s: Store.StoreItems("STORE0000001|STORE0000002|really long list" contains storeitemname))
    then
        System.out.println("Discount!");
end