About this task
Once the autocomplete dictionary has been created, you must populate it using Input
sources. There are two types of input sources that can be used with autocomplete: an input
source from a search collection (discussed in this section), and an input source from a text
file (discussed in the next section).
An autocomplete input source from a search collection extracts phrases from content element
text nodes in a collection and stores them in the autocomplete dictionary.
To begin adding a search collection input source
- Navigate to the Inputs tab of the
autocomplete-tutorial-dictionary that you have just created
- Click the Add Input Source button.
Note: If you navigated away from the dictionary, click on the list icon (
) next to the Dictionaries link in the left-side navigation bar and click on the name
of the dictionary that you created.
In the window that appears (as shown in Figure 1)
- Select Collection for Autocomplete from the list
- Click Add.
The input source has now been added to your autocomplete dictionary.
- You must define:
- Which search collection the phrases will be extracted from
- Which content elements in that collection will be extracted
- If any metadata will be collected for any phrase that is collected
Enter example-metadata in the Collection Name field, which instructs
the dictionary to use the example-metadata collection as this input source.
When creating your own autocomplete dictionary, the content elements that will be used
as phrases must be carefully chosen. The phrases that are collected should ones that you
consider to be valid in a query. For example, if we added the snippet content element to
the autocomplete dictionary, the phrases would be very long (too long for the
autocomplete suggestion box to return) and many words will be repeated in multiple
phrases, which will make the user work harder to refine their query.
The example-metadata collection contains two content elements that are
appropriate to add to an autocomplete dictionary, title and hero. Add
title and hero to the Contents field, each word on a new
line.
Optionally, metadata can also be extracted and stored with the phrases. The metadata
can then be used to enhance the results provided to the user. The display automatically
identifies some metadata contents and uses them to enhance the result. These contents
elements are:
- url - Turns the suggestion into a link to that URL instead of going to the
search results for that phrase.
- image - Hotlinks the image url in an <img> to the left of the
autocomplete suggestion.
- description - Displays the content of the description below the autocomplete
suggestion.
The example-metadata search collection has a content element named url,
so add url to the Metadata field.
Note: Metadata is only collected if specified in the input source. If the
metadata is not collected, it cannot be used to enhance an autocomplete
suggestion.
- For this tutorial, the other fields can be left at the default values.
For more information on these fields, see the Building Autocomplete Data from a
Search Collection section of the autocomplete documentation.
When complete, your search collection input source will look like Figure 2.
- Click OK to complete the configuration of this input
source.