Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Query completion functionality is provided by the autocomplete module module.  This This module provides the back end to support a number of different providers for query completion (autocompletion) suggestions.  

Postcloak

Table of Contents

AIE Attivio Platform ships with two three default query-completion providers.:

Provider ClassDescription
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

via configured

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

based on a manual

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

EntityDictionaryProvider

AutocompleteDictionaryProvider instead as this will support live modifications to the dictionary.

Example EntityDictionaryProvider AutocompleteDictionaryProvider Configuration:

Code Block
languagehtml/xmltitle<project-dir>\conf\features\text
themeDJango
title<PROJECT_DIR>/conf/features/autocomplete/AutoComplete.xml
<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:

Code Block
languagetext
themeDJango
title<PROJECT_DIR>/conf/features/autocomplete/AutoComplete.xml
<fac:autocomplete>
  <fac:providers>
    <fac:provider name="dictionaryProvider" class="com.attivio.autocomplete.providers.EntityDictionaryProvider">
      <fac:property name="dictionaryName" value="autocompleteMyAutocompleteDictionary"/>
      <fac:property name="defaultLocale" value="en"/>
    </fac:provider>
  </fac:providers>
</fac:autocomplete>

Example CustomDictionaryProvider Configuration:

Code Block
html/xml
languagetext
themeDJango
title<project-dir>\conf\features\<PROJECT_DIR>/conf/features/autocomplete/AutoComplete.xml
<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>

...

The AggregateProvider merges results from other autocomplete providers. You can merge the results through a variety of different mixing strategies.

...

Example of an AggregateProvider that consists of two individual EntityDictionaryProviders:

Code Block
languagehtml/xmltext
themeDJango
title<project-dir>\conf\features\<PROJECT_DIR>/conf/features/autocomplete/AutoComplete.xml
<fac:autocomplete>
  <fac:providers>
    <fac:provider name="source1" class="com.attivio.autocomplete.providers.EntityDictionaryProvider">
      <fac:property name="dictionaryName" value="autocomplete-source1entityDictionary1"/>
      <fac:property name="defaultLocale" value="en"/>
    </fac:provider>

    <fac:provider name="source2" class="com.attivio.autocomplete.providers.EntityDictionaryProvider">
      <fac:property name="dictionaryName" value="autocomplete-source2entityDictionary2"/>
      <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

providersnames of the sub-providers, concatenated in a single value (not a JSON-list)noall listed in AggregateProvider definitionall listed in AggregateProvider definition
mixermixing strategy to usenosimple, roundrobin, alpha"defaultMixer" property in AggregateProvider definition
subhitsnumber of suggestions to retrieve from each sub-providerno 10
hits(richCgi) / rows(richPost)number of suggestions to return total, across sub-providers, after mixingno 10

Example Request

endpoint

method

example

richCgiGET http://yourAieHost:17000/rest/autocompleteApi/richCgi/aggregate?q=foo&hits=10 &subhits=2&providers=source1,source2&mixer=roundrobin
richPostPOST

http://yourAieHost:17000/rest/autocompleteApi/richPost/aggregate

With POST payload:

{
  "query": "foo",
  "rows": "10",
  "restParams": { 
    "subhits": ["2"],
    "providers": ["source1,source2"], 
    "mixer": ["roundrobin"] 
  }
}

...

Each suggestion in the final list will contain a "label" and "value" (the suggested completion) and "category" (the provider which returned the suggestion).

http://localhost:17000/rest/autocompleteApi/richCgi/aggregate?q=g&hits=10&subhits=2&providers=source1,source2&mixer=roundrobin

[
{"label":"gary","value":"gary","category":"source1"},
{"label":"george","value":"george","category":"source2"},
{"label":"geoff","value":"geoff","category":"source1"}
]

...

Additional providers can be easily added by customers by implementing the following interface and then registering those providers in their features file.

Code Block
Java
Javalanguagejava
themeDJango
/** 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  document describes how to use the various output formats of the autocomplete module.

...