Integrating a search page widget

Use the Sitecore Discover Search and Recommendation API to integrate a search page widget in your website.

Before you call the Search and Recommendation API to request search page data, identify the website page on which you want the widget to appear. You can add a search page widget to an existing page or create a new page for the widget. On the page, create UI components to hold search page widget data.

Then, on the Customer Engagement Console (CEC), identify the search page widget you want to use. Make sure that you publish the widget before integrating.

Now, you are ready to call the Discover Search and Recommendation API to request search page data and then identify the response parts that you want to feed into your website's UI components.

Best Practices

The following are best practices for creating requests and reading responses to integrate a search page widget.

When you create a request:

  • Do not choose which facets you want to display when you create an API request. Use all facets that appear in the response. If you want only certain facets to appear, edit facets in the CEC before you integrate.

  • When you create a request to call the search result's second (or later) page make sure that everything except the page number is identical to the first page's request. This ensures that your search results look consistent.

  • To handle the autocorrect suggestions that Discover provides, add a suggestion object and a request_for key.

  • For the best latency performance, do not exceed an n_item of 24. Any value higher than 24 slows down the API response time.

When you read a response:

  • Get the order of facets from the facet_names array, the facet name from the display_name key of the response facet object, and the content from the value key of the response facet object.

  • To handle redirect URLs set up in the CEC, search for the redirect_url key in the response. For example, if your business team sets up a rule in the CEC that redirects a search for school shoes to kids' black shoes, you will see the redirect_url key in the response. You must ensure that the search redirects to the page for kids' black shoes.

Do you have some feedback for us?

If you have suggestions for improving this article,