Writing hook script code for specific search types

Managed by | Updated .

Background

By default hook scripts will run on all search requests including those run by content auditor and also extra searches. This article shows how to run hook script code only on the main search, or for specific types of extra searches.

Conditional code based on the search question type can be used to write hook script code that only affects the data model question and response for the specific searches.

Possible values for the question type are:

  • SEARCH
  • SEARCH_GET_ALL_RESULTS
  • EXTRA_SEARCH
  • CONTENT_AUDITOR
  • CONTENT_AUDITOR_DUPLICATES
  • ACCESSIBILITY_AUDITOR
  • ACCESSIBILITY_AUDITOR_ACKNOWLEDGEMENT_COUNTS
  • ACCESSIBILITY_AUDITOR_GET_ALL_RESULTS
  • FACETED_NAVIGATION_EXTRA_SEARCH

Examples

Run hook script code only for the main search (not for extra searches)

The following code block allows you to specify code that will only run only for the main search. The code should be added to the relevant hook script.

import com.funnelback.publicui.search.model.transaction.SearchQuestion.SearchQuestionType;

...

SearchQuestionType questionType = transaction.getQuestion().getQuestionType();

// Only run this code for the main search.
if (questionType.equals(SearchQuestionType.SEARCH)) {
    // Whatever you want to do...

}

Run hook script code only for the content auditor extra search

The following code block allows you to specify code that will only run on the content auditor request. The code should be added to the relevant hook script.

import com.funnelback.publicui.search.model.transaction.SearchQuestion.SearchQuestionType;

...

SearchQuestionType questionType = transaction.getQuestion().getQuestionType();

// Only run this code for the CONTENT_AUDITOR extra search type.
if (questionType.equals(SearchQuestionType.CONTENT_AUDITOR)) {
    // Whatever you want to do...

}
Was this artcle helpful?

Tags
Type: Keywords:
Features:
Frontend > Modern UI Frontend > Hook scripts Frontend > Extra searches Frontend > Faceted navigation

Comments