Type-ahead in ATG Search works by referring to a pre-generated list of possible values that can be used to complete the user’s input. For example, you might want to use a list of products, frequently asked questions, or most-commonly-searched strings. The list can be generated using database tools or can be populated manually. In addition to the text values, the file contains ranking information, which determines the order in which values are returned. The default is to return values in descending order by rank.
For example, your type-ahead file could contain the following product names and associated ranks:
bolt (small)1
bolt (large)2
bolt cutter3
bottle opener4
grommet5
If the user types “bol” in the search field on your site, a dropdown list appears, populated with the following selections, in rank order:
bolt cutter
bolt (large)
bolt (small)
This information must be provided in the form of an XML file. The file can have any name, and is formatted as a simple key-value pair:
<typeAhead lang="language
" min="3" max="10" top="5">
<t v="1">bolt (small)</t>
<t v="2">bolt (large)</t>
...
</typeAhead>
Replace language
with the name of the language you are using, such as English. The t
element contains the text to use for the type-ahead, ordered by the ranking indicated in the v
attribute.
The attributes of the typeAhead
element are:
lang
—The language of the data, which should match the query language to use for searching. The LANGUAGE must be a loaded language that is loaded in the Search Administration project (see the next section). If you want to provide type-ahead in more than one language, you must generate separate files for each language.min
—The minimum size of a key to store, and therefore the minimum entered characters before the UI should submit a request.max
—The maximum size of a key to store. Requesting results with a longer key will simply truncate the key.top
—The maximum text results to store under each key.
Remember that by default, XML uses UTF-8 encoding. If your customization data file includes non-UTF-8 characters, specify the correct encoding in the XML file header:
<?xml version="1.0" encoding="ISO-8859-1"?>
If your XML file is extremely large, you can break it up into as many separate files as you want to make them more manageable. If you do have multiple XML files, attributes in the first file loaded are used for the entire set.
Once you have the list of ranked values, you can make it available to your site.