MozSearch supports search suggestions; as the user types in the search bar, Firefox 2 queries the URL specified by the search engine plugin's
<SuggestionUrl> element to fetch live search suggestions.
Once the list has been retrieved, it's displayed in a popup box that appears under the search bar, which lets the user select a suggested search term. If the user continues to type, a new set of suggestions is requested from the search engine, and the displayed list is refreshed.
The Yahoo and Google search plugins included with Firefox 2 support search suggestions.
Implementing suggestion support in the search plugin
The search plugin specifies the
<SuggestionUrl> to query for a list of search suggestions. The search term is appended to this URL, then queried using an HTTP
For example, the Yahoo search plugin has this
If the user types "fir" into the search bar, then pauses, Firefox appends "fir" to the
<SuggestionUrl>, then queries that URL:
The results are used to construct the suggestion list box.
See Creating MozSearch plugins to learn more about how to implement a search plugin.
Implementing search suggestion support on the server
When the browser wants to fetch possible matches for a search term, it appends the search term to the
<SuggestionUrl> then sends an HTTP
GET request to that URL.
Your server should then decide upon the suggestions to offer using whatever means it sees fit, and construct a JSON result, which is formatted like this:
["search term", [match list]]
search term is the search term that was queried, and the match list is a comma-deliniated, quoted list of suggested terms. For example, if the search term is "fir", you might return the following JSON:
["fir",["firefox","first choice","mozilla firefox"]]
You can return however many suggestions you like, although keeping it to a manageable number is recommended.