Curator - Groovy trigger

This feature is not available to users of the Squiz Experience Cloud version of Funnelback.

The Groovy trigger determines whether or not the trigger fires by running a section of administrator-defined Groovy code. This code must be in the form of a class which implements Funnelback’s com.funnelback.publicui.curator.trigger.GroovyTriggerInterface interface.

Parameters

classFile

The full path to the Groovy class file which defines the trigger.

properties

A map of key-value entries allowing additional configuration information to be provided to the Groovy class.

Example configuration

The trigger section of a curator rule in the $SEARCH_HOME/conf/<collection>/<profile>/curator.json configuration file may be updated to have:

"trigger" : {
    "type" : "Groovy",
    "classFile" : "/path/exampeTrigger.groovy",
    "properties" : {
        "key" : "value"
    }
}

Example class implementation

The following example is an implementation of a trigger called 'TestTrigger' which fires at random on 50% of requests.

Note that the class implements the com.funnelback.publicui.curator.trigger.GroovyTriggerInterface which requires the implementation of the activatesOn method which defines the trigger logic. The activatesOn method accepts two parameters, one being a representation of the search transaction being performed (allowing the user’s query or similar to be determined) and the other being the parameters passed from the configuration file as described above.

import com.funnelback.publicui.search.model.transaction.SearchTransaction;
import java.util.Random;

public class TestTrigger implements com.funnelback.publicui.curator.trigger.GroovyTriggerInterface {
  def boolean activatesOn(SearchTransaction searchTransaction, Map<String, Object> properties) {
    return new Random().nextBoolean();
  }
}

See also