Plugin search lifecycle interface

Introduction

The search lifecycle interface allows a plugin to execute code that performs query-time modifications to the question and response data model. This is equivalent to the modifications made by hook scripts in previous versions of Funnelback.

Interface methods

To interact with the search life cycle, you will need to implement the SearchLifeCyclePlugin interface.

The SearchLifeCyclePlugin provides four different methods:

  • void preProcess(SearchTransaction transaction)

  • void preDatafetch(SearchTransaction transaction)

  • void postDatafetch(SearchTransaction transaction)

  • void postProcess(SearchTransaction transaction)

Each of these should manipulate the SearchTransaction object which contains both the query under question and results under response. These methods run at the same time that their corresponding groovy hook scripts ran in the life cycle.

Usage

Once the plugin is enabled, searches will immediately begin using the plugin methods.

Example: title-prefix-plugin

The developing your first plugin guide runs through the process of creating a search lifecycle plugin. This plugin replaces a pattern at the start of a title in matching search results.

Example: clean-title-plugin

Removes a pattern from a title.

Testing

When writing unit tests for the SearchTransaction use the following helper classes to generate the mock data sent to your tests:

  • TestableSearchTransaction

  • SearchQuestionTestHelper

Logging

Log messages will appear in the search package’s user interface logs.