Search Providers in IE8
Simple steps on how to install and extend search providers in IE8.
Installation of a Search Provider
This can be done in the following ways:
1) Automatically, the web page might have a link or button for this.
2) By discovery, when the provider’s search page has been loaded, the Instant Search box turns to orange indicating that there is one or more search providers in the current page.
3) Manually, follow the instructions from (1).
Search Provider may support the following feature for better user experience:
4) Search Suggestions (with text and images) either XML based on JSON[1] based.
5) Search Preview (via the accelerator button, you can find more on the accelerator in (2)).
Implementing your own Search Provider
Two things should be done in order to expose your web search page as a search provider in IE8, create an OpenSearch Description XML file (3) and promote the file through your web page.
The OpenSearch Description XML
This is a simple small XML file that defines the following:
Search provider attribute in OpenSearch XML |
Description |
ShortName |
The name of the provider |
URL |
The absolute URL of the search provider |
Image |
A favico file URL (optional) |
JSON suggestions URL |
The JSON suggestion URL (optional) |
XML suggestions URL |
The XML based suggestion URL (optional) |
Preview URL |
The URL with the preview (used from the accelerator button) – (optional). |
Note: Each URL has a placeholder for search tokens, this is the query string parameter that represents the keyword(s) to search through your provider.
The following is a sample of an OpenSearch XML (source (4)).
<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="https://a9.com/-/spec/opensearch/1.1/" xmlns:ie="https://schemas.microsoft.com/Search/2008/">
<ShortName>My Custom Search</ShortName>
<Image height="16" width="16" type="image/icon">https://example.com/example.ico</Image>
<Url type="text/html" template="https://example.com/search.aspx?q={searchTerms}&source=IE"/>
<Url type="application/x-suggestions+json" template="https://suggestions.example.com/search.aspx?q={searchTerms}"/>
<Url type="application/x-suggestions+xml" template="https://suggestions.example.com/search.aspx?q={searchTerms}"/>
<ie:PreviewUrl type="text/html" template="https://suggestions.example.com/search.aspx?q={searchTerms}"/>
</OpenSearchDescription>
Promoting your Search Provider
In order to “promote” the aforementioned XML file the client’s IE browser you need to do one of the following:
§ Provide a link or a button that “Adds” the search provider to the client’s IE browser, or
§ Make your provider’s OpenSearch XML discoverable.
Add your Search Provider via Javascript
You may use a link or a button to promote your OpenSearch XML by using the following javascript:
Javascript for adding your search provider:
window.external.AddSearchProvider('https://yourprovidersite/provider.xml');
Making your OpenSearch XML discoverable
You can accomplish that by adding a LINK element in the HEAD html tag. The LINK element should have the following form:
<link title="My Provider" rel="search"
type="application/opensearchdescription+xml"
href="https://yourprovidersite/provider.xml">
When your page is loaded the Instant Search box turns to orange and you may add the provider(s) of your page with a single click.
Offering Search Suggestions
Search suggestions provide the ability to retrieve search results as the user is typing the search token(s). While typing IE8 calls the search URL of the provider with the typed token, if the provider is suitable (i.e. supports suggestions) returns a list of result.
Results should be formed in either of the following ways:
§ Using the JSON suggestion format, and/or
§ Using the XML suggestion format
Both formats supports images (to be displayed in the quick search results list at the top right corner) and immediate navigation to a result page without navigating to the search results page of the search provider.
IE 8 displayed up to 10 suggestions.
JSON Suggestion Format
This format is based on Jscript array of arrays. The array contains the following:
JSON Array parameter |
Description |
Query string |
The search keyword |
Suggestions array |
The array with the results |
Array with descriptions (optional) |
An array with descriptions of the results |
Instant answers URL |
An array with URL for instance answers (links in the result list for direct access to the result) |
XML suggestions URL |
The XML based suggestion URL (optional) |
Preview URL |
The URL with the preview (used from the accelerator button) – (optional). |
A simple sample of JSON response is the following:
["search Token",
["search result 1", "search result 2", "search result 3"]]
["search Token",
["result 1", "result 2", "result 3"],
["result 1 description", "result 2 description", "result 3 description"],
["result 1 URL","result 2 URL", "result 3 URL"]]
XML Suggestion Format
The format for suggestions in XML is as follows:
<?xml version="1.0"?>
<SearchSuggestion xmlns="https://schemas.microsoft.com/Search/2008/suggestions">
<Query>search token</Query>
<Section>
<Item>
<Text>result 1 title</Text>
<Description>result 1 description</Description>
<Url>result 1 URL</Url>
</Item>
<Item>
<Text>result 2 title</Text>
<Description>result 2 description</Description>
<Url>result 2 URL</Url>
</Item>
<Item>
<Text>result 3 title</Text>
<Description>result 3 description</Description>
<Url>result 3 URL</Url>
</Item>
…
</Section>
</SearchSuggestion>
You may also define separators in the ITEM elements as follows:
…
<Separator title=”separator title”>
<Item>
<Text>result 3 title</Text>
<Description>result 3 description</Description>
<Url>result 3 URL</Url>
</Item>
…
</Separator>
…
References
1. MSDN. Add Search Providers to Internet Explorer. [Online] https://www.microsoft.com/windows/ie/searchguide/en-uk/default.mspx?dcsref=https://runonce.msn.com/runonce2.aspx.
2. —. OpenService Accelerators Developer Guide. [Online] https://msdn.microsoft.com/en-us/library/cc287851(VS.85).aspx.
3. Specifications/OpenSearch/1.1/Draft 4 - OpenSearch. [Online] OpenSearch.org. https://www.opensearch.org/Specifications/OpenSearch/1.1.
4. MSDN. Search Providers Extensibility in Internet Explorer. [Online] https://msdn.microsoft.com/en-us/library/cc848862(VS.85).aspx.
5. —. XML Search Suggestions Format Specification. [Online] https://msdn.microsoft.com/en-us/library/cc848863(VS.85).aspx.