Skip to main content
RichRelevance

service/typeAhead

https://recs.richrelevance.com/rrserver/api/v1/service/typeAhead/{apiKey}?search=<searchTerm>

Note: The URL requires the API key and parameter(s) to function properly. See below for more information on example URL requests.

Description: Get type ahead suggestions for a keyword prefix.

Parameters

Note: All paramets are case sensitive.

Name Required or Optional Description
apiKey Required

A unique key that identifies the site. Each RichRelevance client has a unique API key to separate data and traffic from other clients. This is provided by RichRelevance.

Example: apiKey=4faeaf752ee40a0f

search Required

The prefix search term.

Example Request

NOTE: This is only an example to indicate the proper syntax of the request. In order to make this work you must replace the api key and search terms.

GET http://recs.richrelevance.com/rrserver/api/v1/service/typeAhead/f20dc17e1482cd47?search=de

In this example, the request would return up to 5 suggested search terms that start with the prefix “de”.

Example Response

[
 
{ "score": "1", "term": "depth 4-door refrigerator with flexzone&trade", "id": "RF24FSEDBSR/AA", "type": "product" }
 
,
 
{ "score": "5", "term": "depth 4-door flex&trade french door", "id": "RF23J9011SR/AA", "type": "product" }
 
,
 
{ "score": "4", "term": "depth french door refrigerator stainless", "id": "RF18HFENBSR/AA", "type": "product" }
 
,
 
{ "score": "3", "term": "depth side-by-side food showcase refrigerator", "id": "RH22H9010SR/AA", "type": "product" }
 
,
 
{ "score": "2", "term": "depth side-by-side refrigerator stainless steel", "id": "RS22HDHPNSR/AA", "type": "product" }
 
]

Example web implementation

We have provided reference code (JavaScript, HTML and CSS) that you can use to integrate the type ahead suggestion user experience into your existing search box. We expect you to modify this code to conform to the UX principles and guidelines of your website.

The following is a sample page that demonstrates how to retrieve and display the suggested search terms and product recommendations.

<html>
    <head>
    <script src="typeAhead_reference.js"></script>
     
    $(document).ready(function () {
      $('#search-input').sayt({
        inputWidth: '400',
        setInputValueOnSelection: true,
        fadeTime: 0,
        debug: false,
        imageHeight: 80,
        imageWidth: 80,
        removeImageProtocol: true,
        sourceIsInstantSearchBooleanQueryParam: 'fromInstantSearch',
     
        termsUrl: 'http://recs.richrelevance.com/rrserver/api/v1/service/typeAhead/<API_KEY>?search=',
     
        productsUrl: 'http://recs.richrelevance.com/rrserver/api/rrPlatform/recsForPlacements?apiClientKey=<API_CLIENT_KEY>&apiKey=<API_KEY>&placements=search_page.typeAheadSearch_1&jsonp=true&searchTerm=',
        productsJsonpCallbackParameterName: 'jcb'
     
      }).focus();
    });
    </head>
 
    <body>
      <div id="Search_Example" class="container">
        <div class="main-app">
          Instant Search   
          <p/>
          <form action="" class="search-form">
            <input id="search-input" class="search-box" name="q" id="example-box" size="48" placeholder="Search" autocomplete="off">
            <input type="hidden" name="fromInstantSearch" value="false"/>
          </form>
        </div>
      </div>
    </body>
</html>

Download: typeAhead_reference.js

  • Was this article helpful?