LoginSignup
0
0

More than 1 year has passed since last update.

AWS OpenSearchじゃない方のOpenSearchについて

Posted at

この記事のOpenSearchとは

Search Engine

OpenSearchプロトコルとは、ユーザーが自分の好きな検索エンジンやサイトをブラウザに追加できるようにする仕様です。これにより、ユーザーはブラウザのアドレスバーから直接、追加した検索エンジンやサイトを検索することができます。

ただし、OpenSearchと検索すると、AWSのOpenSearchが上位に表示されるため、この記事ではOpenSearchプロトコルと表記します。ちなみに、OpenSearchプロトコルはAmazonの子会社であるA9.comが提案した仕様です。とても紛らわしいです。

OpenSearchプロトコルの概要

OpenSearchプロトコルは、ブラウザから利用可能な検索プロトコルであり、検索結果をXML形式で返します。
ウェブサイトは、OpenSearch Description Documentと呼ばれるXMLファイルを提供し、ユーザーはブラウザ上で検索クエリを入力して検索結果を取得できます。OpenSearchプロトコルは、A9.comによって2005年に導入され、現在では広く普及しています。

OpenSearchプロトコルの記述方法

penSearch Description Documentは、検索エンジンやウェブサイトが提供する検索機能をブラウザから利用するためのXMLファイルであり、検索エンジンの名前や検索結果のURLなどを記述します。OpenSearch Description Documentは、htmlのヘッダ部にlinkタグで宣言します。

<link href="/opensearch.xml" rel="search" title="Qiita" type="application/opensearchdescription+xml">

OpenSearch Description Documentのフォーマット

OpenSearch Description Documentの各項目と説明を表形式でまとめると以下のようになります。

要素 説明
ShortName 検索エンジンの短い名前を表します。
Description 検索エンジンの説明を表します。
Tags 検索エンジンに関連するタグを表します。
Contact 検索エンジンに関する問い合わせ先のメールアドレスを表します。
Url 検索結果を返すURLを表します。type属性で、text/htmlまたはapplication/rss+xmlを指定します。
Image 検索エンジンを表すアイコンのURLを表します。width、height、type属性を含みます。
InputEncoding 検索エンジンに送信される検索クエリのエンコーディングを表します。
OutputEncoding 検索結果のエンコーディングを表します。
Developer 検索エンジンの開発者を表します。
Attribution 検索結果の提供元を表します。
SyndicationRight 検索結果の配信に関する著作権情報を表します。
AdultContent 検索結果にアダルトコンテンツが含まれるかどうかを表します。
Language 検索結果の言語を表します。
OutputEncoding 検索結果のエンコーディングを表します。

BingのOpenSearch Description Documentの例を以下に示します。

<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
    <ShortName>Bing</ShortName>
    <Description>Bing search</Description>
    <Tags>bing, search, web</Tags>
    <Contact>webmaster@microsoft.com</Contact>
    <Url type="text/html" method="get" template="https://www.bing.com/search?q={searchTerms}&amp;pc=MOZI&amp;form=MOZSBR"/>
    <Url type="application/rss+xml" template="https://www.bing.com/search?q={searchTerms}&amp;format=rss"/>
    <LongName>Bing Web Search</LongName>
    <Image height="64" width="64" type="image/png">https://www.bing.com/s/a/bing_p_rr_teal_min.ico</Image>
    <Developer>Microsoft Corporation</Developer>
    <Attribution>Search results provided by Bing</Attribution>
    <AdultContent>false</AdultContent>
    <Language>en-us</Language>
    <OutputEncoding>UTF-8</OutputEncoding>
</OpenSearchDescription>

上記の例では、ShortName、Description、Tags、Contactなどの要素に検索エンジンの情報を記述しています。また、Url要素では、検索結果のURLを指定することができます。type属性でtext/htmlを指定したUrl要素は、検索結果をHTMLフォーマットで返すURLであり、template属性に{searchTerms}というパラメーターを含んでいます。このパラメーターには、ユーザーが入力した検索クエリが入ります。

また、type属性にapplication/rss+xmlを指定したURLも定義されており、RSS形式で検索結果を返すことことがわかります

OpenSearchプロトコルの利用例

提供しているサイト

OpenSearchプロトコルをサポートするWebサイトの例を以下に示します。

サイト名 ShortName opensearch.xmlのパス
google Google https://www.google.com/searchdomaincheck?format=opensearch
wikipedia Wikipedia (en) https://en.wikipedia.org/w/opensearch_desc.php
twitter Twitter https://twitter.com/opensearch.xml
Yahoo! Japan Yahoo! JAPAN http://search.yahoo.co.jp/opensearch.xml
Goo goo https://search.goo.ne.jp/xml/websearch.xml
IT用語辞典 e-Words IT用語辞典 e-Words http://e-words.jp/opensearch.xml
rubygems RubyGems.or https://rubygems.org/opensearch.xml

サポートしているブラウザー

OpenSearchプロトコルをサポートしている主要なブラウザーとそのバージョンを以下に示します。

ブラウザー バージョン
Google Chrome バージョン 20以降
Mozilla Firefox バージョン 2以降
Microsoft Edge バージョン 80以降
Safari バージョン 6以降

以上が、OpenSearchプロトコルの利用例に関する情報です。

関連検索

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0