Skip to content


Personalization in Ecommerce Search can be configured using Affinities.

Affinities are properties of products that users might have preferences for. For example, users might prefer sugar-free soda, sustainably caught fish, or a specific brand. In those cases, affinities can be used to customize the commercial sorting of products towards a certain customer, depending on the commercial affinities of the products and the user affinities of the customer.

There are two types of affinities: Commercial affinities and user affinities. Both have to be provided from an external source into Ecommerce Search.

Commercial affinities are placed on items, such as products. For example, a fragrance-free shampoo might have a slight item affinity towards the “perfume-free” affinity. The same shampoo might be made sustainably, which might cause a higher affinity towards the “sustainability” affinity.

User affinities are connected to user ids. They model the preferences of an individual customer of the store. If a customer prefers sugar-free products, they will have a high score in the “sugar-free” affinity.

All affinities, both user and commercial affinities are within the interval [0:1), and the sum of all item or user affinities on an item or a user respectively are also within the same interval of [0:1).

After calculating the affinity of the user towards an item, the affinity score is multiplied by the personalization weight set in Ecommerce Search. This weight determines the overall weight of personalization against the score attributions of commercial parameters and search relevance.


In practice a user's affinity profile is not only directed towards a single product attribute, but instead it comprises a vector of affinities towards a vector of attributes with arbitrary length. This allows product affinities to capture each customer's unique and complex preferences.

To the individual shopper, product affinities places products with increased individual relevance higher up on the PLPs than possible with wisdom-of-the-crowd. Furthermore, affinity-based relevance scores is not tied to the product numbers or SKUs and so a newly introduced product will be correctly scored from the get-go. This is usually not the case for wisdom-of-the-crowd merchandising (number of clicks, adds to basket, etc.), where new products are born with score 0.

User affinity sources

When ingesting user affinities, a source must be specified. The source allows Ecommerce Search to boost different sources of user affinities with different weights.

Each affinity source may calculate affinities differently, such as:

  • How likely a user is to buy a product by comparing the user's shopping habits with other users.
  • A user could have favorite products they buy often.
  • A user may have products, which they buy at regular intervals. The users affinity towards those products would then increase when it has been a while since they last bought the products.

Using affinities for commercial sorting

Ecommerce Search will provide affinities after they have been ingested. Commercial affinities are provided within the commercial properties of items.

Example of scoring with affinities

Say a user has the following user affinities for the two customers Alex (A) and Bill (B):

Cruelty-free Fragrance-free Parabens-free
Alex 0.5 0.1 0.4
Bill 0.1 0.7 0.2

And there are two products in the store. Shampoo 1 is marked as moderately high in the commercial affinity cruelty-free. It is also free of parabens resulting in an item affinity score towards “parabens-free”. Shampoo 2 is not marked as cruelty-free, but it is fragrance-free and also free of parabens.

Cruelty-free Fragrance-free Parabens-free
Shampoo 1 0.5 0 0.2
Shampoo 2 0 0.4 0.2

The items do not have commercial properties and both are hits on the search phrase of the customer. As such, only the affinities of the customers towards the products plays a role. The affinity scoring for the two customers will look as such:

This is how the scoring of affinities is done in Ecommerce Search:

Alex Bill
Shampoo 1 0.5 * 0.5 + 0.1 * 0 + 0.4 * 0.2 = 0.33 0.1 * 0.5 + 0.7 * 0 + 0.2 * 0.2 = 0.09
Shampoo 2 0.5 * 0 + 0.1 * 0.4 + 0.4 * 0.2 = 0.12 0.1 * 0 + 0.7 * 0.4 + 0.2 * 0.2 = 0.32

This affinity scoring is then multiplied by the context affinity weight to get the personalization contribution of the commercial score of a product. As the commercial value score contribution and phrase match score are the same for the two products, they have no impact on the final product sorting order.

The final commercial sorting of the two products will be Shampoo 1 first and Shampoo 2 second for Alex and Shampoo 2 first and Shampoo 1 second for Bill.

Example of scoring with multiple affinity sources

The previous example had just one affinity source which resulted in the score:

Alex Bill
Shampoo 1 0.33 0.09
Shampoo 2 0.12 0.32

Another affinity source looking at the users favorite products could calculate the users affinities to the following:

Alex Bill
Shampoo 1 0.1 0.9
Shampoo 2 0.9 0.1

Assuming affinity source 1 has a weight of 2, and affinity source 2 has a weight of 1, the final affinity score of the two products would be calculated like this.

Alex Bill
Shampoo 1 0.33 * 2 + 0.1 * 1 = 0.76 0.09 * 2 + 0.9 * 1 = 1.08
Shampoo 2 0.12 * 2 + 0.9 * 1 = 1.14 0.32 * 2 + 0.1 * 1 = 0.65

Enabling personalization

In order to use Personalization, enable it in General Settings. In ContextWeights endpoint, set the personalization weight with a value for a specific context.