I want to write custom methods which I can use while defining my business rules. This can be index time rules or search time rules.
You could follow the steps mentioned below to create a Java class with helper methods that you require and then use them in your business rules.
- Create the Java class with the helper functions required. You could have a look at the structure of DroolsHelper.class mentioned here - http://docs.lucidworks.com/display/lweug/Drools+Integration
- Compile the Java class using - "javac com/rules/MyHelper.java".
- To create a JAR file run - "jar cf jar-name.jar com/rules/MyHelper.class"
- Place the JAR in the following directory "$LWS_HOME/app/webapps/lwe-core/lwe-core/WEB-INF/lib/" -
- Create your rule in any of the .drl files under "$LWS_HOME/conf/solr/cores/[core-name]/conf/rules/"
- Don't forget to import the methods you have defined in the .drl file - "import function come.rules.MyHelper.*;"
- Use the functions you have defined in the "then" section of your rule file.
- Restart the LWS server