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:

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.

 
loading table of contents...