Plugin: auto-completion-plugin
| Other versions of this plugin may exist. Please ensure you are viewing the documentation for the version that you are currently using. If you are not running the latest version of your plugin we recommend upgrading. See: list of all available versions of this plugin. |
This plugin can be used to create auto completion suggestions based on the trigger provided in the collection.cfg.
Imagine you have a data source which contains staff details of a university. Once you have configured relevant metadata for the staff members' name, this plugin can create auto completion suggestions based on the name of the staff member. So when a user comes along and starts typing "Stev" in a search box, this plugin can start suggesting staff such as "Steve" and "Steven" who both contain the letters "Stev" in their name.
Enabling the plugin
Add the following to profile.cfg to enable the plugin.
plugin.auto-completion-plugin.enabled=true
plugin.auto-completion-plugin.version=1.0.0
In addition to enabling the plugin above, you can configure where suggestions are sourced from by defining the following setting:
plugin.auto-completion-plugin.config.trigger=<where to source trigger values from>
-
Default value:
plugin.auto-completion-plugin.config.trigger=title
Once you enable this plugin or change the above trigger, you need to re-index your data source in order for the auto completion suggestions to be generated.
Configuring the plugin
The main part of configuring this plugin is to set an appropriate trigger to compare to. Before we get into it, lets look at some terminology we’ll be using in the following examples.
Terminology
-
Partial Query: what the user has typed in to a search input box so far. e.g. 'Stev'
-
Suggestion: the query completion suggested to the user as a possible auto-completion of their partial query. e.g. 'Steven'
-
Trigger: The name of the field in which to look for suggestions e.g. 'metadata.firstName'
Valid values
This plugin currently supports the following triggers:
| trigger | Description |
|---|---|
|
(Default) Suggestions will be sourced from the document title |
|
Suggestions will be sourced from the |
| If there’s no value specified for the trigger, or if the plugin can’t find the provided metadata then the plugin will take the title of the result object as the trigger. |
Example
Given a collection with a few example records in the staff directory:
[{
...
title: "Steven Smith | Senior Lecturer",
url: "http://funnelback-university/staff/123",
listMetadata: [
firstName: ["Steven"],
lastName: ["Smith"],
]
...
}, {
...
title: "Steve Wonder | Fellow",
url: "http://funnelback-university/staff/456",
listMetadata: [
firstName: ["Steve"],
lastName: ["Wonder"],
]
...
}, {
...
title: "Jane Doe | Dean",
url: "http://funnelback-university/staff/789",
listMetadata: [
firstName: ["Jane"],
lastName: ["Doe"],
]
...
}]
If the plugin was configured with:
plugin.auto-completion-plugin.config.trigger=metadata.firstName
When a user starts searching for "Stev", this plugin will compare "Stev" against ["Steve", "Jane", "Steven"] and offer "Steve" and "Steven" as suggested query completions.
If instead, the plugin was configured with:
plugin.auto-completion-plugin.config.trigger=title
The suggestions might be: "Steven Smith Senior Lecturer" and "Steve Wonder Fellow"