OpenSearch
OpenSearchとは、米アマゾン子会社のA9.com社が提唱する検索エンジン提供者のための技術の名称で、検索結果を他のサイトから自由に利用できるようにするための仕組みのことである。
OpenSearchを利用すれば、複数の検索サイトにクエリーを投げて、その結果をクライアントやWebサイト側で合成・加工して表示するといったことが可能になる。国内のサイトでは、「はてな」や「仁王.jp」などがこの仕組みを活用している。
OpenSearchを構成している基本的な要素としては、
- OpenSearch RSS … OpenSearchで検索結果を出力するためのXMLフォーマット
- OpenSearch Description Documents … 利用されている検索エンジンを特定したり識別するためのXML文書
- OpenSearch Aggregators … OpenSearchの検索結果を表示することができる仕組み
という三つの仕組みが上げられる。
OpenSearchとは オープンサーチ: - IT用語辞典バイナリ
<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
<ShortName>Web Search</ShortName>
<Description>Use Example.com to search the Web.</Description>
<Tags>example web</Tags>
<Contact>admin@example.com</Contact>
<Url type="application/rss+xml"
template="http://example.com/?q={searchTerms}&pw={startPage?}&format=rss"/>
</OpenSearchDescription>
OpenSearch description document - Specifications/OpenSearch/1.1/Draft 5 - OpenSearch
| 要素 | 目的 |
|---|---|
| ShortName | |
| Description | |
| Url | |
HTMLやXHTML文書では、head要素内で次のようにレスポンスを返します。
<head>
<title>***</title>
<link rel="search"
type="application/opensearchdescription+xml"
href="http://example.com/opensearchdescription.xml"
title="Example.com Web Search" />
<meta name="totalResults" content="4230000"/>
<meta name="startIndex" content"1"/>
<meta name="itemsPerPage" content="10"/>
</head>
<?xml version="1.0"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">
<ShortName>Wikipedia (en)</ShortName>
<Description>Wikipedia (en)</Description>
<Image height="16" width="16" type="image/x-icon">https://en.wikipedia.org/static/favicon/wikipedia.ico</Image>
<Url type="text/html" method="get" template="https://en.wikipedia.org/w/index.php?title=Special:Search&search={searchTerms}" />
<Url type="application/x-suggestions+json" method="get" template="https://en.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}&namespace=0" />
<Url type="application/x-suggestions+xml" method="get" template="https://en.wikipedia.org/w/api.php?action=opensearch&format=xml&search={searchTerms}&namespace=0" />
<moz:SearchForm>https://en.wikipedia.org/wiki/Special:Search</moz:SearchForm>
</OpenSearchDescription>
https://en.wikipedia.org/w/opensearch_desc.php
<link rel="search"
type="application/opensearchdescription+xml"
href="/w/opensearch_desc.php" title="Wikipedia (en)"/>
Wikipedia
<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">
<ShortName>はてなブックマーク検索</ShortName>
<Description>はてなブックマーク検索</Description>
<InputEncoding>utf-8</InputEncoding>
<Image width="16" height="16">http://b.hatena.ne.jp/favicon.ico</Image>
<Url type="text/html" method="GET" template="http://b.hatena.ne.jp/search/text?q={searchTerms}" />
</OpenSearchDescription>
http://b.hatena.ne.jp/opensearch.xml
<link rel="search"
type="application/opensearchdescription+xml"
title="はてなブックマーク検索"
href="/opensearch.xml" />
はてなブックマーク