OpenSearch

At work we use several Atlassian products, including JIRA and Confluence. We recently upgraded to the latest version of both, and when that happened I noticed Chome starting to behave a little differently. One day I was typing in https://jira (the path to our internal instance), and all of a sudden Chrome's URL bar changed, and I had a search directly of JIRA.

Typing in "confluence", followed by a space, did the same thing. (our confluence server is also just https://confluence).

Cool, but how does that work? I fired up WireShark, which wasn't much help since our JIRA runs on HTTPs. I figured maybe there was a special file (much like robots.txt, favicon.ico, etc) that was being requested by the browser when it hit the url "https://jira". After doing some digging online, it turns out that I was wrong. There is a spec called OpenSearch, which ultimately is a XML format that describes how to interact with a search engine. Furthermore, there is a <link rel="search"> that you can add to your pages that will instruct the browser where to get an OpenSearch document from. Best I can tell is that Chrome caches these.

Every page in JIRA has the following:

<link rel="search" type="application/opensearchdescription+xml" href="/osd.jsp"
title="JIRA Ticket System"/>

When hitting that URL, this is what is returned:

<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">
<ShortName>JIRA Ticket System</ShortName>
<Description>Atlassian JIRA Search Provider</Description>
<Image height="16" width="16" type="image/x-icon">https://jira/images/16jira.png</Image>
<Image height="64" width="64" type="image/png">https://jira/images/64jira.png</Image>
<Url type="text/html" template="https://jira/secure/QuickSearch.jspa?searchString={searchTerms}"/>
<Query role="example" searchTerms="JIRA"/>
<InputEncoding>UTF-8</InputEncoding>
<moz:SearchForm>https://jiram/secure/QuickSearch.jspa</moz:SearchForm>
</OpenSearchDescription>

I'm not 100% sure, I'll have to check tomorrow, but I believe Chrome keys the magic off of either the <ShortName> in the OSD file, or the title in the <link rel="search">. What is interesting is that both have the same text, and have "Inc." at the end, but the period is missing from the screenshot above. Since our JIRA server is the only site producing "JIRA...." in the ShortName, maybe Chrome believes that is where I want to search. I need to do a little more research on this.

OpenSearch is used by others. If you go to Amazon.com, theirs behaves a little differently. The xml file that is selected varies based on the browser you use. In Chrome 8, I saw a <link rel="search">, but the href attribute was blank. If you visit Amazon with Firefox, then click on the drop-down for your selected search engine in the search box in your browser, you will see "Add Amazon Search Suggestions". I'll have to see what JIRA does in Firefox tomorrow.

Leave a Reply