Loading...
Area: Episerver Search & Navigation, Episerver Personalized Search & Navigation
Applies to versions: 12.6 and higher (Find)

Personalized Search & Navigation

Recommendations [hide]

Personalized Search & Navigation (formerly Personalized Find) is a personalization service that you can add to Episerver Search & Navigation (formerly Episerver Find)  as part of the Episerver Personalization product suite. This topic describes the native integration for Search & Navigation, and how to work with search attributes and values provided with the search client to boost search hits.

Note: Personalized Search & Navigation currently only works with Episerver Commerce.

Integration packages

In addition to Episerver.Find, these packages are needed for the integration:

  • EPiServer.Personalization.Commerce. Integration for product recommendations.
  • EPiServer.Find.Personalization. Search & Navigation integration components.

See the Personalization section how to get started with Personalized Search & Navigation.

Integration components

Personalized Search & Navigation fetches attributes from a personalization service, which contains a list including property name, property value, and boosting. The list will be included as “boosting” with the Search & Navigation service when doing a search, or filtering content.

The boosting changes the generated “score” on content, to make the result personalized. This functionality will have different impact on the result pending on the query, and on what attributes that are returned from the personalization service.

Configuration

To enable retrieval of search attributes, configure the Attribute API. The required attributes are episerver:personalization.Site and episerver:personalization.ClientToken. See Episerver Recommendations for information about configuring the Recommendations API.

Retrieving attributes

Before executing a personalized Search & Navigation query, the attributes must be fetched from the Recommendations API. This is not a quick process, so the attributes must be fetched and stored or cached for fast retrieval before the user needs them. In this way, latency is not adversely affected when a site visitor executes a query or filter.

Attributes can be retrieved in the ways described below.

Calling the Refresh method

You can call the Refresh method on an instance of the EPiServer.Find.Personalization.IPersonalizationClient. To retrieve the active EPiServer.Find.Personalization.IPersonalizationClient instance, call the Personalization() extension on EPiServer.Find.Personalization.IClient.

using EPiServer.Find.Personalization;

namespace EpiserverSite.Controllers
  {
    public class MyController : PageController<MyPage>
      {
        private readonly IClient _client;
        public MyController(IClient client)
          {
            _client = client;
          }
        public ActionResult Index(MyPage currentPage)
          {
            System.Threading.Tasks.Task.Factory.StartNew(currentContext =>
              {
                System.Web.HttpContext.Current = (HttpContext)currentContext;
                _client.Personalization().Refresh();
              },
            HttpContext.Current.ApplicationInstance.Context);
            return View(currentPage);
          }
      }
  }

Decorating a controller with RefreshPreferences

You can decorate a controller with an EPiServer.Find.Personalization.RefreshPreferences attribute. This gets attributes from the API when any action method on the controller is executed. To avoid unnecessary refreshing, check the IPreferenceRepository for attributes first, or use the controller to track if a refresh has already been done for the visitor.

namespace EpiserverSite2.Controllers
  {
    [EPiServer.Find.Personalization.RefreshPreferences]
    public class MyController : PageController<MyPage>
      {
        public ActionResult Index(MyPage currentPage)
          {
            return View(currentPage);
          }
      }
  }

The Recommendations API call is done asynchronously, so has little effect on the time to execute the controller.

After retrieval, the attributes are stored in an EPiServer.Find.Personalization.IPreferenceRepository. The default implementation stores the attributes in the session and in a cookie, for fast retrieval during the session or between sessions no longer than 2 days apart.

If you want to override the default, implement EPiServer.Find.Personalization.IPreferenceRepository and change the implementation using the conventions during initialization: IClient.Personalization().Conventions.PreferenceRepository. The interface has two methods to implement, Save and Load, which are self explanatory.

Executing personalized search queries

To enable personalization in Episerver Search & Navigation queries, add .UsingPersonalization() to the query on the search client. The results are scored according to attribute data.

Example

var result = _client.Search<ProductContent>()
  .For("ferrari")
  .UsingPersonalization()
  .GetContentResult();

Related topics

Do you find this information helpful? Please log in to provide feedback.

Last updated: Jun 17, 2020

Recommendations [hide]