Package com.funnelback.filter.api
Interface FilterContext
-
- All Superinterfaces:
InternalFilterContext
public interface FilterContext extends InternalFilterContext
An immutable context supplied to the filters.The context can be used to get values from the collection configuration the filter is running under.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description String
getCollectionName()
Gets the name of the collection under which the filter is run.Set<String>
getConfigKeys()
Gets the set of all configuration keys for collection the filter is running under.Map<String,List<String>>
getConfigKeysMatchingPattern(String pattern)
Provides config settings which match the given key pattern.Set<String>
getConfigKeysWithPrefix(String prefix)
Provides a list of config setting keys which have some prefix.Optional<String>
getConfigValue(String key)
Gets the value of the configuration setting for the collection the filter is running under.DocumentTypeFactory
getDocumentTypeFactory()
Provides a DocumentTypeFactory, may be used to constructFilterDocumentFactory
getFilterDocumentFactory()
Provides a DocumentTypeConverter, used to convert between filterable document types.Optional<String>
pluginConfigurationFile(String filename)
Reads a configuration file for the currently running plugin as a UTF-8 String.Optional<byte[]>
pluginConfigurationFileAsBytes(String filename)
Reads a configuration file for the currently running plugin.-
Methods inherited from interface com.funnelback.filter.api.InternalFilterContext
filterConfigurationFile, filterConfigurationFileAsBytes, getCollectionConfigFile
-
-
-
-
Method Detail
-
getCollectionName
String getCollectionName()
Gets the name of the collection under which the filter is run.- Returns:
- the collection name the filter is running under.
-
getConfigKeys
Set<String> getConfigKeys()
Gets the set of all configuration keys for collection the filter is running under.- Returns:
- all configurations keys.
-
getConfigValue
Optional<String> getConfigValue(String key)
Gets the value of the configuration setting for the collection the filter is running under.- Parameters:
key
- used to lookup the configuration value.- Returns:
- the value for the key from the configuration if the key exists in the configuration otherwise returns empty.
-
getConfigKeysWithPrefix
Set<String> getConfigKeysWithPrefix(String prefix)
Provides a list of config setting keys which have some prefix. This is useful in cases where you need to process some set of config values (e.g. one setting per data source). Example: A prefix of 'myfilter' will match 'myfilter.foo' and 'myfilter.foo.bar'.
-
getConfigKeysMatchingPattern
Map<String,List<String>> getConfigKeysMatchingPattern(String pattern)
Provides config settings which match the given key pattern. The pattern is the same pattern used for configuration permissions. Some examples are: pattern 'a.*' matches 'a.foo' but does not match 'a.foo.bar' pattern 'a.*.*' matches 'a.foo.bar' but does not match 'a.foo' The key within the returned map is the full key and the value is a list of the parameters for the key. For example if config has: 'a.foo.bar' and 'a.b.c' and the pattern is 'a.*.*' the resulting map will contain: 'a.foo.bar': ["foo", "bar"] 'a.b.c': ["a", "b"] Note that if the config key contains '.' or '\' it will be escaped as it is in config. For example if config contains 'a.c:\\bar\.jpg' then for the pattern 'a.*' the resulting map would contain: 'a.c:\\bar\.jpg': ["c:\bar.jpg"] The key remains escaped however the paramaters in the list are left unescaped.- Parameters:
pattern
-- Returns:
- a map of all matching config keys where the key in the map is the config key and the value is a list of all parameters.
-
getFilterDocumentFactory
FilterDocumentFactory getFilterDocumentFactory()
Provides a DocumentTypeConverter, used to convert between filterable document types. The implementation provided under testing may differ from the implementation provided under Funnelback e.g. during a crawl.- Returns:
-
getDocumentTypeFactory
DocumentTypeFactory getDocumentTypeFactory()
Provides a DocumentTypeFactory, may be used to construct- Returns:
-
pluginConfigurationFileAsBytes
Optional<byte[]> pluginConfigurationFileAsBytes(String filename)
Reads a configuration file for the currently running plugin. The configuration file read is for the currently running plugin and either the data source or search package the plugin is currently running on. When a plugin is run during a search, this will be the results page (profile) the search is running on. Plugins can not read the configuration files for other plugins.- Parameters:
filename
- the name of the configuration file to read.- Returns:
- empty if the file doesn't exist, otherwise the contents of the file.
-
pluginConfigurationFile
Optional<String> pluginConfigurationFile(String filename)
Reads a configuration file for the currently running plugin as a UTF-8 String. See:pluginConfigurationFileAsBytes(String)
- Parameters:
filename
- the name of the configuration file to read.- Returns:
- empty if the file doesn't exist, otherwise the contents of the file.
-
-