Search Service/Suggestions

From MozillaWiki
Jump to: navigation, search
  • This is a draft, please wait until it is not a draft to comment *

Search Suggestion Service

In Firefox 2, search plugins will be able to specify a suggestions URL (via a a special <Url> element), which can be queried for match-as-you-type style completions, similar to Google Suggest.

Results Format

Results should be returned in JSON format. Servers may optionally return data in JSONP wrapper to other clients, but that is not necessary or supported within Firefox itself.

The returned result should be an array of four elements, the first being the query string, the second being an ordered array of completions, the third being an optional array of descriptions for the second object, and the fourth being an optional array of query URLs for the second object. More information is provided in the sections below.

Query String

Required: Yes

Description: In order to provide a sanity check against out of order results, the query string is returned as the first element in the array.

Completions

Required: Yes

Description: A set of suggested completions for the query string as an array. For instance, "fir" may match "firefox", "first choice", and "mozilla firefox"

An example of a search result with the previous matches would be ["fir",["firefox","first choice","mozilla firefox"]]

Descriptions

Required: No

Description: An array of descriptions for the first array of results.

Query URLs

Required: No

Description: An array of alternate URLs for the first array of results