Suggester
As an example here, these are things that you must add to yoursolrconfig.xml file to get suggestions based on matching against a title field, as well as looking up terms in your main content field.
http://localhost:8983/solr/sample/suggest?q=al (replace ‘al’ with the string the end-user has typed) will bring back suggestions for both suggesters in this format:
Accessing the Solr Suggest component in Appkit
Appkit provides two different services to access Solr suggestions depending on whether or not backwards compatibility (set via thebackwardsCompatible attribute) is enabled.
Backwards compatibility is disabled
When backwards compatibility is disabled, use theSolrQuerySuggestionService to access suggestions. In resources/conf/services/suggestions, create a configuration file (for example, querySuggestions.conf) to contain the configuration parameters for the suggestion service. Here is an example of how this might look:
name and source attribute are required. The name indicates which suggestion service is used. The source gives the id for accessing the platform configuration attributes.
The remaining attributes shown here are optional. If parenthesis is set to true, the query value, equated with the URL parameter suggest.q, will be surrounded by parenthesis. The title attribute gives a title to the list of suggestions. Custom parameters can also be set on the query. For example, count[5] translates to count=5 on the query URL.
Backwards compatibility is enabled
When backwards compatibility is enabled, use theSolrSuggestionsParserService to access suggestions. In resources/conf/services/suggestions create a configuration file (for example, querySuggestions.conf) to contain the configuration parameters for the suggestion service. Here is an example of how this might look:
name and source attributes are required. The source attribute here refers to a Fusion platform configuration, which must have the backwardsCompatible attribute set to true. The other required attribute for this service is suggester. This is the name of the Solr suggester as defined in the solrconfig.xml. For example, using the example above, suggester could be set to titleMatchSuggester or freeTextContentSuggester.
The remaining attributes shown here are optional and are the same as described above for when backwards compatibility is disabled.
Terms component
The Solr terms component “provides access to the indexed terms in a field and the number of documents that match each term”. This can be used, for example, to find all terms in the Solr index that match an expansion of the given query term. For example, “car” might return CARRY, CARRIED, CARE, CARL etc.Accessing the Solr Terms component in Appkit
To access the Terms component in Appkit, use theSolrQueryTermsService. In resources/conf/services/suggestions create a configuration file (for example, queryTerms.conf) to contain the configuration parameters for the terms suggestion service. Here is an example of how this might look:
name and source attributes are required as well as the term-fields attribute. The name indicates which suggestion service is used. The source gives the configuration name for accessing the Solr platform’s configuration attributes (in the example shown above the platform configuration would be stored in resources/conf/platforms/solr/suggestions/terms.conf. Within this platform configuration the requestHandler attribute mat be defined. However, by default, this is set to /terms.
The term-fields attribute is equivalent to the terms.fl parameter required by the Solr Terms Component. It is a comma-separated list of fields from which to retrieve terms. In the example above, only one field, Symbol, is used.
The title attribute gives a title to the group of suggestions that are returned by Solr. This title can be used to group suggestions in the UI.
Referring to the suggestion and/or terms service in the search:box
Finally, to ensure your application hooks into the suggestion and/or terms service when it is run, place this line inside your<search:box>: