Autocomplete, also known as auto-suggest, look-ahead, or type-ahead, is a feature that displays a list of common search terms that begin with, or are contained by, the query string. For example, the query "search technology" might result in an autocomplete list with results "search technology rocks", "i love search technology", and/or "this is a search technology company", depending on how the autocomplete has been configured. Like most other search components, Fusion leverages Solr’s autosuggest component. Assuming auto-suggest is configured in the Solr config, it is sufficient to enable it in Fusion in order to use the component.
Choose a suggester implementation from the Solr Suggester documentation and define it in the solrconfig.xml file.
In this example, a suggester called mySuggester is created in solrconfig.xml using the AnalyzingInfixLookupFactory and defining 'description' as the field to be suggested on:
<searchComponent name="suggest" class="solr.SuggestComponent"> <lst name="suggester"> <str name="name">mySuggester</str> <str name="lookupImpl">AnalyzingInfixLookupFactory</str> <str name="dictionaryImpl">DocumentDictionaryFactory</str> <str name="field">description</str> <str name="suggestAnalyzerFieldType">string</str> <str name="buildOnStartup">false</str> </lst> </searchComponent>
Ensure that the field used for autosuggest is properly defined in the schema.
<field name="description" type="text_general" stored="true" indexed="true" multivalued="false" />
Once modified, the custom configuration files can be uploaded to Zookeeper using Zookeeper’s command line interface.
The zkcli command
putfilecan be used to replace an existing ZK configuration file. Here
CONFIG_NAMEwill likely represent the name of the collection, otherwise the name of a custom configuration that has been defined.
fusion/4.0.x/apps/solr-dist/server/scripts/cloud-scripts/zkcli.sh -z localhost:2181 -cmd putfile /configs/CONFIG_NAME/solrconfig.xml /Desktop/solrconfig.xml
Enabling autosuggest in Fusion requires adding the "suggest" request handler to the AllowedRequestHandlers in the "Solr Query" stage of the query pipeline. The suggester should then be built using