Using Java Processors

The App Studio Workflow module provides out of the box processors to manipulate queries and responses from the underlying search engine, as well as an SDK to write your own Java processors.

Implementing processors

You need to make some configuration changes to set up processors on your platforms. There are two ways, the simplest is directly on the platform config file, when the processor requires no arguments. For more complex processors that take input arguments there are additional steps.

Query Processor

Example: Add the user name to the query filtering on the ‘username’ field. Get the username either from the query payload itself or from the security provider.

src/main/conf/platforms/fusion/data.conf →

query-profile: my-profile
workflow: twigkit.client.processor.query.AddUser

src/main/java/twigkit/client/processor/query/ →

package twigkit.client.processor.query;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import twigkit.model.Filter;
import twigkit.model.Query;
import twigkit.model.Value;
import twigkit.processor.QueryProcessor;
public class AddUser extends QueryProcessor {
  private static final Logger logger = LoggerFactory.getLogger(AddUser.class);
  private SecurityProvider securityProvider;
  public Query change(Query payload) {
      if (payload != null) {
          Filter userFilter = new Filter();
          Value user = new Value();
          if (securityProvider != null) {
              if (securityProvider.getUser() != null) {
              } else {
                  logger.error("No user retrieved from " + securityProvider.getClass().getName());
          } else if (payload.getUser() != null) {
          } else {
              logger.error("No SecurityProvider provided and no user on the query!");
      return payload;

Response processor with configuration

Example: If the response has no results send the query again to a different platform.

src/main/conf/platforms/fusion/fusion.conf →

requestHandler: /select
query-profile: my-profile
workflow: processors.response.fuzzy-search

src/main/conf/platforms/fusion/fuzzy.conf →

requestHandler: /spell

src/main/conf/processors/response/fuzzy-search.conf →

name: twigkit.client.processor.response.FuzzySearch
fuzzy-platform: platforms.fusion.fuzzy


package twigkit.client.processor.response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import twigkit.conf.ConfiguredPlatformProvider;
import twigkit.model.Query;
import twigkit.model.Response;
import twigkit.model.messages.Message;
import twigkit.platform.Platform;
import twigkit.processor.ResponseProcessor;
import java.util.ArrayList;
import java.util.List;
public class FuzzySearch extends ResponseProcessor {
  private static final Logger logger = LoggerFactory.getLogger(FuzzySearch.class);
  private ConfiguredPlatformProvider platformProvider;
  public Response change(Response response) {
      String fuzzyPlatformId = getParameterStringValue("fuzzy-platform");
      Platform fuzzyPlatform = platformProvider.get(fuzzyPlatformId);
      if (response.getHits().getActual() > 0){
          return response;
      } else {
          Query query = response.getQuery();
          Response fuzzyResponse =;
          String queryString = query.getValue().getActualAsString();
          Message fuzzyMessage = new Message();
          fuzzyMessage.setValue("No results found for the term <em>"+queryString+"</em>. Returning results with similar words.");
          List<Message> messages = new ArrayList<Message>();
          return fuzzyResponse;