Custom Operators in Drools Conditions

34 views
Skip to first unread message

Daniel Clark

unread,
Jun 4, 2025, 11:36:51 AMJun 4
to Drools Usage
Hi all,

Does anybody have any documentation or guidance on using custom operators in drools rules (which don't break optimization in the lhs)?

We have a large set of rules on distributed systems and need to maintain backwards compatibility on syntax. We are exploring ways to update our interface for one certain class (which we use a lot), to update one field from a string to list of strings (currently the draft implementation is a custom class extending ArrayList<String>).
We want to potentially override existing list operators (e.g. contains()), and add custom operators (e.g. an exclusive contains), and allow for a single string comparison or a list comparison to maintain backwards compatibility.
This is all possible in java but we will have lots of calls to these operators in the conditions of rules and don't want performance decreases. There is an operator interface in the API and some other evaluators in various kie and mval classes, but I can't find any documentation on extensibility and how this will affect the rete algorithm.

Any tips or guidance will be very welcome!
Thank you,
Daniel

Daniel Clark

unread,
Jun 4, 2025, 1:02:21 PMJun 4
to Drools Usage
Sorry I forgot version info! We are currently using version 7.72.0.Final. We should be migrating to 10.0.0 in the near future but had some technical dependencies preventing further updates until recently.

Toshiya Kobayashi

unread,
Jun 4, 2025, 8:53:56 PMJun 4
to drools...@googlegroups.com
Hi,

I have filed a PR to add the "Custom Operator" section to the official docs. It will likely be available to 10.1.0 docs.

https://github.com/apache/incubator-kie-docs/pull/4565/files

I hope this helps
Toshiya


--
You received this message because you are subscribed to the Google Groups "Drools Usage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drools-usage...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/drools-usage/4d4f5b45-0419-44e8-8f45-ac471ca757a3n%40googlegroups.com.

Daniel Clark

unread,
Jun 5, 2025, 7:46:38 AMJun 5
to Drools Usage
Hi Toshiya,

Yes that helps a lot, thank you! I recongise the superset operator from a sample Mario shared for a very old drools version but couldn't find enough information to build it completely. Thank you for the exhaustive example!
I have tried out a few custom operators using the 7.72 methods (which are very close to the version 10 methods), which work well, and will run some performance tests against the plain java function variants (out of interest if for no other reason).

Kind regards,
Daniel

Toshiya Kobayashi

unread,
Jun 6, 2025, 4:35:55 AMJun 6
to Drools Usage
Hi Daniel,

I look forward to the performance test results. IMHO, there wouldn't be much difference, because both a custom operator and a java function method are eventually a java method call, and they are not involved in specific engine optimizations (e.g. node sharing, indexing), but I may overlook something. Let's see.

Regards,
Toshiya

2025年6月5日木曜日 20:46:38 UTC+9 Daniel Clark:
Reply all
Reply to author
Forward
0 new messages