Controlling what metadata fields are returned with each search result

Metadata can be used to enhance search results by providing richer information for the result summaries, or to provide fields that conditional template code can be based off.

By default, Funnelback will return metadata from the author, c (description), publisher and subject classes in the search results or data model. There are a number of display settings that affect how metadata is returned to the user.

Configuring metadata display options

Metadata is returned as part of each search result, unless summaries are disabled (by setting -SM=off as a query processor option.)

The list of metadata fields returned with the search results is determined by the summary fields (SF) query processor option. The fields to return are defined as a comma separated list of class names surrounded by square brackets (e.g. -SF=[t,author,keyword,description] instructs Funnelback to return the t (title), author, subject and description fields with the result set). The list supports a regex expression that will match multiple metadata fields. (e.g. -SF=[fun.*] will return all fields beginning with fun and -SF=[.*] will return all defined fields.)

using the wildcard matches for fields is convenient but can result in a performance hit if there is a lot of metadata fields (as this bloats the size of the result packet that must be returned by Funnelback.)

Once these two settings have been configured metadata will be returned in the data model (for both JSON and XML endpoints) along with the other fields for each result.

Returned metadata is placed in the following sub-element within each search result:

  • listMetadata: contains the value of the metadata class as a list of strings, with multiple values as separate values in the list.

Advanced display options

  • Metadata buffer size (MBL) : Controls the size of the buffer used to store metadata summaries. This value may need to be increased if metadata values are being cut off. Set using the MBL parameter.

Using metadata in Freemarker

The Freemarker templates can make use of any metadata that is available in the data model.

To print out the content of a metadata class use the following inside an <@s.Results> template block.

<#if s.result.listMetadata?keys?seq_contains("CLASSNAME")>
    <#list s.result.listMetadata["CLASSNAME"] as item>${item}</#list>
<#else>
	do something else
</#if>

e.g. print out the first author value

<ul>
<li>Author: ${s.result.listMetadata["author"]?first!"Unknown"}</li>
</ul>

To print out all the author metadata values from the listMetadata element:

<#if s.result.listMetadata?keys?seq_contains("author")>
    <#list s.result.listMetadata["author"] as a><p><@s.boldicize>${a}</@s.boldicize></p></#list>
</#if>

Use metadata in a conditional test

Metadata can be used as the basis of a conditional test.

If the author metadata is defined then print out the author’s name

<#if s.result.listMetadata?keys?seq_contains("author")>
	The author is ${s.result.listMetadata["author"]?first}
</#if>

If the document classification is top secret then print out a message

<#if s.result.listMetadata["documentClassification"]?first == "Top secret">
	Nothing to see here
</#if>