algolia-opensearch-suggestions

Service to convert Algolia Query Suggestions to OpenSearch Suggestions.

MIT License

Stars
7

algolia-opensearch-suggestions

Service to convert Algolia Query Suggestions to OpenSearch Suggestions.

Picture of Firefox showing Algolia Query Suggestions from the URL bar with OpenSearch Suggestions.

Usage

Query parameters

Example
https://your-website.com/.netlify/functions/suggestions?query=iphone&appId=appId&apiKey=apiKey&indexName=indexName&hitsPerPage=3

Returns

["iphone",["iphone","iphone 6s","iphone gray"]]

Add OpenSearch to your website

<OpenSearchDescription
  xmlns="http://a9.com/-/spec/opensearch/1.1/"
  xmlns:moz="http://www.mozilla.org/2006/browser/search/"
>
  <!-- ... -->
  <!-- Replace the query parameters with your Algolia credentials -->
  <Url
    type="application/x-suggestions+json"
    template="https://your-website.com/.netlify/functions/suggestions?query={searchTerms}&amp;appId=latency&amp;apiKey=6be0576ff61c053d5f9a3225e2a90f76&amp;indexName=instant_search_demo_query_suggestions&amp;hitsPerPage=10"
  />
</OpenSearchDescription>
opensearch.xml
<html>
  <head>
    <link
      rel="search"
      type="application/opensearchdescription+xml"
      href="opensearch.xml"
      title="Search app"
    />
    <!-- ... -->
  </head>
  <body>
    <!-- ... -->
  </body>
</html>
index.html

Resources

License

MIT