Oracle ATG Web Commerce Search supports a type-ahead feature that attempts to automatically complete the query text as the user enters it in a search form. As the user types in the text box, a drop-down list is displayed listing possible query text that matches the characters entered. For example, if the user types “bla”, the dropdown may display “black”, “bland”, and “blank”. If the user then types “n”, the dropdown now displays only “bland” and “blank”, because the typed substring no longer matches “black”. At any point, the user can select a text string from the dropdown, and it will be entered in the text box. The user can then click the submit button to issue a query with the selected text, or can ignore the dropdown and type in the complete text to search for.

Implementing type-ahead involves creating two pages:

Note that the type-ahead data and the catalog data are included in the same index, so an additional search engine instance is not required. However, using separate indexes (and therefore separate search engine instances) is highly recommended for performance reasons.

The examples in this section use the Ajax.Autocompleter function from the script.aculo.us open source JavaScript library. For information about this library, see:

http://script.aculo.us

You can use an autocompleter function from a different JavaScript library instead, though you might then need to implement a different servlet bean or form handler to use on the type-ahead page.

The WAR file for the QueryConsole sample application includes the script.aculo.us JavaScript files. The WAR file is located at:

<ATG10dir>/DAF/Search/Base/QueryConsole/web-apps/queryconsole.war

This chapter includes the following sections:

For information about configuring Oracle ATG Web Commerce Search to use type-ahead data, see the ATG Search Administration Guide.