Best practices - 3.2 Using custom data in the data model


This article outlines how to use custom data when implementing Funnelback.

Custom data elements

The Funnelback data model has various customData elements that can be used to hold custom data that can then be accessed from hook scripts and Freemarker templates.

  • question.customData: This should be used to hold any custom data that is added before the query runs.

  • response.customData: This should be used to hold any non-specific custom data that is added after the response is returned.

  • result.customData: This should be used to hold any result-specific custom data.

Use result.customData instead of injecting custom data into the result.metaData element as custom fields. Although it is possible to add to the existing element it can be confusing because other features may be dependent on the metaData element and not work as expected if you compare the output to what is in the data model. e.g. if you inject additional metadata fields to hold custom data you can’t then use metadata sorting on these fields (because this happens before the results are returned from Funnelback).