Funnelback logo

Documentation

Result transform (collection.cfg)

Description

This option allows you to perform a simple transformation on the results from a query, with the Classic user interface. The same effect can be achieved with the Modern interface using user interface hook scripts.

The result transform is a Perl expression that is executed for each result.

Result elements, such as the title and live_url, can be referenced by using the Perl variable:

$$result{ name }

The element names are detailed in the Result element page.

Caveats

  • This code is executed without any checks for validity or functionality.
  • Syntax errors may be difficult to find -- check your web server's error logs.
  • Historically $$_ was used instead of $$result. $$_ is still supported, but is considered deprecated.

Default value

(none)

Examples

If you had a Perl script that could generate the summary text for documents, you could replace the summary text from Funnelback with the text generated by your script:

result_transform=$$result{summary} = `get-summary.pl '$$result{live_url}'`

The back-tick characters form the Perl syntax for executing a system command.

The following result transform takes the "z" metadata field (in this case representing a username mapped from an XML document), and capitalizes the first letter in each word, turning "john smith" into "John Smith" and "jane doe" into "Jane Doe".

result_transform=$$result{'md_z'} =~ s/\b(\w)/\U$1/g;

See metadata troubleshooting for help with metadata classes.

Security

Results transforms allow the execution of administrator supplied Perl code, which has security implications should untrusted administrators be allowed to supply result transforms. See search form security.

See also

top ⇑