Search client-side configuration - Bloomreach Experience - Open Source CMS

Search client-side configuration

Configuring Search

Define the following variable in render.js with the appropriate configurations for Search:

Variable in render.js:

var F = BR.mobile.apiFields;
// you can extend the F parameter to include more field names (e.g., F["product_type"] = "product_type";)
var searchConfig = {
    accountId: <Bloomreach Provided Account ID>,
    authKey: '',
    domainKey: 'merchant_com',
    environment: 'staging',
    renderFunction: renderResultsPage,
    errorCallback: renderError,
    timeout: 2000,
    fieldNames: [F.pid, F.title, F.brand, F.price, F.sale_price, F.promotions, F.thumb_image, F.sku_thumb_images, F.sku_swatch_images, F.sku_color_group, F.url, F.price_range, F.sale_price_range],
};
  
var renderResultsPage = function(results) {
};
  
var renderError = function(errorMessage) {
}

Search configuration parameters

This table provides a list of each parameter and a description. Use these parameters to configure your client-side integration

Parameter Name

Required

Type

Description

Example

accountId Required integer

The ID of the account sending the request. Your Bloomreach integration team provides this ID to you.

 
authKey Required string The authentication key for the account sending the request. You must pass this parameter, but you can send it empty for client-side integration. Your Bloomreach integration team provides this key to you. 3c641ab5b543cb3a642da
domainKey Required string The ID of the domain receiving the request. Your Bloomreach integration team provides this key to you. debshops_com
environment Required string (enum)

The string that determines which server to retrieve data from. Use one of the following values:

  • 'staging' is your test environment.
  • 'prod' is your production environment. It's not a good idea to move new code to 'prod' without first testing it on 'staging'.

Don't forget to use the single quotes ( ' ) around the string; they aren't optional.

'staging'
numResults Optional  

The maximum number of search results to show

 Default: 10

 
renderFunction Required  

Contains a results object that's used to render the Search page. Use the following format to call this function with a single argument that contains the search results and accompanying data: Search Results Format your_argument.

see detailed information about the renderFunction parameter 


Detailed information

renderFunction parameter

The most important part of searchConfig is renderFunction. When the Search plugin receives a response from the search servers, it processes the response to create a results object, passing the object to renderFunction as an argument. You can use this object to render the Search page. Take a look at Structuring a search page to see how to use the information in the object to render the page.

Here's a sample response from this function with a single argument that contains the search results and accompanying data:

Search results with renderFunction:

{
   "facet_counts":{
      "facet_fields":{
         "category":[
            {
               "count":800,
               "crumb":"/90000",
               "cat_name":"clearance",
               "parent":"",
               "cat_id":"90000",
               "tree_path":"/90000,clearance"
            },
            {
               "count":593,
               "crumb":"/1001",
               "cat_name":"Junior",
               "parent":"",
               "cat_id":"1001",
               "tree_path":"/1001,Junior"
            },
            {
               "count":505,
               "crumb":"/1001/1089",
               "cat_name":"dresses",
               "parent":"1001",
               "cat_id":"1089",
               "tree_path":"/1001,Junior/1089,dresses"
            }
         ],
         "color_group":[
            {
               "count":360,
               "name":"blue"
            },
            {
               "count":349,
               "name":"black"
            },
            {
               "count":333,
               "name":"orange"
            }
         ],
         "size":[
            {
               "count":672,
               "name":"m"
            },
            {
               "count":639,
               "name":"s"
            },
            {
               "count":589,
               "name":"l"
            }
         ]
      }
   },
   "response":{
      "start":0,
      "numFound":1870,
      "docs":[
         {
            "price":30.5,
            "thumb_image":"http://demandware.edgesuite.net/aahi_prd/on/demandware.static/Sites-DebShops-Site/Sites-debshops-master/default/v1366148706266/images/product/1000041481/1000041481-880-MAIN-170x269.jpg",
            "title":"solid ruffle front belted casual dress",
            "pid":"1000041481",
            "brand":"Deb"
         }
      ]
   }
}

 

Did you find this page helpful?
How could this documentation serve you better?
On this page
    Did you find this page helpful?
    How could this documentation serve you better?