Define additional metadata mappings using a plugin

The plugin indexing interface provides a method metadataMappings() which enables additional metadata mappings to be registered within a data source.

The primary use case for this is to set up any metadata mappings that are required to support a plugin, such as mapping known metadata fields for a new social media gatherer.


In order to add a metadata mapping, your plugin must be configured to provide indexing functionality.

Add a metadata mapping

To create metadata mappings, implement the metadataMappings() method within this java class.

void metadataMappings(IndexConfigProviderContext context, MetadataMappingConsumer consumer)

Within this method, you need to call the map() method on the consumer for each mapping you wish to set up.

The void map(String metadataClass, MetadataType type, MetadataSourceType sourceType, String locator) method takes four parameters:


The name of the metadata class which may be used at query time. Must be less than 65 characters and must be ASCII alphanumeric.


The type of the metadata class, e.g. NUMERICAL for numeric values. Acceptable values are defined in the MetadataType enum.


This indicates the type of the source metadata field. e.g. HTML_OR_HTTP_HEADERS if the metadata is coming from <meta name="author" content="John Doe">. Acceptable values are defined in the MetadataSourceType enum.


The location to get the metadata from e.g. when getting metadata from HTML: <meta name="author" content="John Doe"> the locator would be "author".

Example: Provide additional metadata mappings

This example, extracted from the social tags plugin shows how to define metadata mappings within a plugin.
package com.funnelback.plugin.socialtags;

import com.funnelback.plugin.index.consumers.MetadataMappingConsumer;
import com.funnelback.plugin.index.model.metadatamapping.MetadataSourceType;
import com.funnelback.plugin.index.model.metadatamapping.MetadataType;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import com.funnelback.plugin.index.IndexConfigProviderContext;
import com.funnelback.plugin.index.IndexingConfigProvider;

public class SocialTagsIndexingConfigProvider implements IndexingConfigProvider {

    private static final Logger log = LogManager.getLogger(SocialTagsIndexingConfigProvider.class);

    public void metadataMappings(IndexConfigProviderContext context, MetadataMappingConsumer consumer) {
        log.debug("Add metadata mapping for social tags metadata");, MetadataType.TEXT_INDEXED_AS_DOCUMENT_CONTENT, MetadataSourceType.HTML_OR_HTTP_HEADERS,
            PluginUtils.HASH_TAG_METADATA); (1), MetadataType.TEXT_INDEXED_AS_DOCUMENT_CONTENT, MetadataSourceType.HTML_OR_HTTP_HEADERS,
1 Defines a metadata mapping which maps the Plugin-Social-Tags-Hash-Tags metadata field (added via the plugin filter) to a metadata class hashTags in Funnelback. The fields passed to the method:
  • PluginUtils.HASH_TAG_METADATA_NAME: The first field defines the metadata class name that will be created in Funnelback. The variable used here defined in the plugin’s file, and is set to hashTags.

  • MetadataType.TEXT_INDEXED_AS_DOCUMENT_CONTENT: The second field indicates the type of metadata class. In this case the metadata class is set to type Indexed as document content.

  • MetadataSourceType.HTML_OR_HTTP_HEADERS: The third field indicates the type of (source) metadata field. In this case the type is set to HTML meta tag, HTML tag or HTTP headers, which includes metadata added via other plugins or filters.

  • PluginUtils.HASH_TAG_METADATA: The last field defines the (source) metadata field name. In this case it is the example value of one of the following: <meta name="Plugin-Social-Tags-Hash-Tags" content="example value">, an HTML tag <Plugin-Social-Tags-Hash-Tags>example value</Plugin-Social-Tags-Hash-Tags> or a HTTP header Plugin-Social-Tags-Hash-Tags: example value

See also