Home / design

OpenSearch description format

The OpenSearch description format lets a website describe a search engine for itself, so that a browser or other client application can use that search engine. OpenSearch is supported by (at least) Firefox, Edge, Internet Explorer, Safari, and Chrome.

OpenSearch was developed by Amazon.com subsidiary A9 and the first version, OpenSearch 1.0, was unveiled by Jeff Bezos at the O'Reilly Emerging Technology Conference in March, 2005.

On your home page you can add the link to the xml-file, ( in the head-part ).

<link rel="search" type="application/opensearchdescription+xml" id="resourceSearchLink" 
        title="My web Search Service"
        href="https://example.com/opensearchdescription.xml" />

XML-file

The file itself should have at least the following:
<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="https://a9.com/-/spec/opensearch/1.1/">
    <ShortName>My web Search Service</ShortName>
    <Url format="application/rss+xml" 
        template="https://example.com/rss.php?query=
        {searchTerms}&start={startIndex}&cnt={count}" />
</OpenSearchDescription>
Supported token How used by OpenSearch provider
{searchTerms} Replaced with the search terms that the user types in the Windows Explorer search input box.
{startIndex} Used when getting results in "pages".
Replaced with the index for the first result item to return.
{startPage} Used when getting results in "pages".
Replaced with the page number of the set of search results to return.
{count} Used when getting results in "pages".
Replaced with the number of search results per page that Windows Explorer requests.
{language} Replaced with a string that indicates the language of the query being sent.
{inputEncoding} Replaced with a string (such "UTF-16") that indicates the character encoding of the query being sent.
{outputEncoding} Replaced with a string (such as "UTF-16") that indicates the desired character encoding for the response from the web service.

 

Paging Using the Item Index An item index identifies the first result item in a page of results. If you want clients to send requests using an item index, you can use the {startIndex} token in your Url element template attribute.
<Url format="application/rss+xml" 
    template="https://example.com/rss.php?query={searchTerms}&start={startIndex}" />
Page size You may want to configure your web service to permit a request to specify the size of the pages by using some parameter in the URL. A request must be specified in the .osdx file by using the {count} token, as follows:
<Url format="application/rss+xml"
    template="https://example.com/rss.php?query={searchTerms}&start={startIndex}&cnt={count}" />

OpenSearch response

The OpenSearch response can be in RSS 2.0 or Atom 1.0.
Here is an example how a return result should look like in RSS 2.0:
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
     xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/"
     xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Example.com Search: New York history</title>
    <link>http://example.com/New+York+history</link>
    <description>Search results for "New York history" at Example.com</description>
    <opensearch:totalResults>423</opensearch:totalResults>
    <opensearch:startIndex>1</opensearch:startIndex>
    <opensearch:itemsPerPage>10</opensearch:itemsPerPage>
    <atom:link rel="search" type="application/opensearchdescription+xml" href="http://example.com/opensearchdescription.xml"/>
    <opensearch:Query role="request" searchTerms="New York History" startPage="1" />
    <item>
      <title>New York History</title>
      <link>http://www.columbia.edu/cu/lweb/eguids/amerihist/nyc.html</link>
      <description>
        ... Harlem.NYC - A virtual tour and information on
        businesses ... with historic photos of Columbia's own New York
        neighborhood ... Internet Resources for the City's History. ...
      </description>
    </item>
    <!-- ... -->
  </channel>
</rss>

More information in Mozilla OpenSearch,
Microsoft OpenSearch
Or Githib OpenSearch

 

TOP