Overview
Query completion functionality is provided by the autocomplete module. This module provides the back end to support a number of different providers for query completion (autocompletion) suggestions.
View incoming links.
Attivio Platform ships with three default query-completion providers:
Provider Class | Description |
---|---|
AutocompleteDictionaryProvider | Provides suggestions from the set of all published autocomplete dictionaries with locales matching the query's locale. See Manage Dictionaries and Configure Spell Checking to configure autocomplete dictionaries and dictionary locales. (Available in Attivio Platform 5.6.3 and later releases.) |
EntityDictionaryProvider | Provides suggestions from a published entity dictionary with a locale matching the query's locale. See Manage Dictionaries and Configure Spell Checking to configure entity dictionaries and dictionary locales. |
CustomDictionaryProvider | Provides suggestions from a manually-configured dictionary of terms provided by the user. The dictionary file is read only during Attivio node startup. It is recommended that you use AutocompleteDictionaryProvider instead as this will support live modifications to the dictionary. |
Example AutocompleteDictionaryProvider Configuration:
<fac:autocomplete> <fac:providers> <fac:provider name="dictionaryProvider" class="com.attivio.autocomplete.providers.AutocompleteDictionaryProvider"> <fac:property name="defaultLocale" value="en"/> </fac:provider> </fac:providers> </fac:autocomplete>
Example EntityDictionaryProvider Configuration:
<fac:autocomplete> <fac:providers> <fac:provider name="dictionaryProvider" class="com.attivio.autocomplete.providers.EntityDictionaryProvider"> <fac:property name="dictionaryName" value="MyAutocompleteDictionary"/> <fac:property name="defaultLocale" value="en"/> </fac:provider> </fac:providers> </fac:autocomplete>
Example CustomDictionaryProvider Configuration:
<fac:autocomplete> <fac:providers> <fac:provider name="dictionaryProvider" class="com.attivio.autocomplete.providers.CustomDictionaryProvider"> <fac:property name="dictionaryFilename" value="autocomplete/dictionaries/sample.dict"/> <fac:property name="partialMatches" value="true"/> <fac:property name="caseSensitive" value="false"/> </fac:provider> </fac:providers> </fac:autocomplete>
AggregateProvider
The AggregateProvider merges results from other providers. You can merge the results through a variety of different mixing strategies.
At query time, you can specify:
- which other autocomplete providers to aggregate over
- how many suggestions to retrieve from each other provider
- how many suggestions to retrieve total (across all providers)
- a variety of mixing strategies: simple (i.e. grouped), roundrobin, or alphabetical
Upon mixing, duplicate suggestions are omitted (unless the mixing strategy is simple). The purpose of the simple strategy is to keep the results from each provider segregated (effectively the opposite of mixing), assuming that de-duplication is not wanted.
Configuration
You must configure the AggregateProvider with a list of other providers to make them available for selection at query time.
Example of an AggregateProvider that consists of two individual EntityDictionaryProviders:
<fac:autocomplete> <fac:providers> <fac:provider name="source1" class="com.attivio.autocomplete.providers.EntityDictionaryProvider"> <fac:property name="dictionaryName" value="entityDictionary1"/> <fac:property name="defaultLocale" value="en"/> </fac:provider> <fac:provider name="source2" class="com.attivio.autocomplete.providers.EntityDictionaryProvider"> <fac:property name="dictionaryName" value="entityDictionary2"/> <fac:property name="defaultLocale" value="en"/> </fac:provider> </fac:providers> <fac:aggregateProviders> <fac:aggregateProvider name="aggregate"> <fac:provider name="source1"/> <fac:provider name="source2"/> </fac:aggregateProvider> </fac:aggregateProviders> </fac:autocomplete>
Query Parameters
name | description | required? | possible values | default |
---|---|---|---|---|
providers | names of the sub-providers, concatenated in a single value (not a JSON-list) | no | all listed in AggregateProvider definition | all listed in AggregateProvider definition |
mixer | mixing strategy to use | no | simple, roundrobin, alpha | "defaultMixer" property in AggregateProvider definition |
subhits | number of suggestions to retrieve from each sub-provider | no | 10 | |
hits(richCgi) / rows(richPost) | number of suggestions to return total, across sub-providers, after mixing | no | 10 |
Example Request
endpoint | method | example |
---|---|---|
richCgi | GET | http://yourAieHost:17000/rest/autocompleteApi/richCgi/aggregate?q=foo&hits=10 &subhits=2&providers=source1,source2&mixer=roundrobin |
richPost | POST | http://yourAieHost:17000/rest/autocompleteApi/richPost/aggregate With POST payload: { "query": "foo", "rows": "10", "restParams": { "subhits": ["2"], "providers": ["source1,source2"], "mixer": ["roundrobin"] } } |
Example Output
Each suggestion in the final list will contain a "label" and "value" (the suggested completion) and "category" (the provider which returned the suggestion).
[ {"label":"gary","value":"gary","category":"source1"}, {"label":"george","value":"george","category":"source2"}, {"label":"geoff","value":"geoff","category":"source1"} ]
In this example, source1 resulted in two suggestions, and source2 resulted in one suggestion. They were mixed by roundrobin.
Limitations
You cannot use the "simple" and "simpleJsonp" endpoints as they can only accept "q" and "hits" parameters. When using the AggregateProvider, you must use either the "richCgi" or "richPost" endpoints.
Writing Additional Providers
Additional providers can be easily added by customers by implementing the following interface and then registering those providers in their features file.
/** Interface for beans that will provide suggestions for user queries. */ public interface AutoCompleteProvider { /** Get a list of query auto complete suggestions for the specified term. * It should be assumed that this method will be called for each end user keystroke. * Performance of the method should be designed accordingly. * * @return a Map of query values to display values for each suggestion with each suggestion possibly having additional metadata */ List<AutoCompleteSuggestion> getSuggestions(QueryRequest req); }
Client Usage of Auto Complete
The REST Auto Complete API document describes how to use the various output formats of the autocomplete module.