Using personalization
To personalize results for a visitor, use the widget.items.search.personalization object. You must add the fields that you want Sitecore Search to prioritize when looking for similar items and the algorithm you want to use. Also, pass the uuid so that Sitecore Search knows which visitor must get personalized results.
Before you can use an attribute for personalization, make sure that an administrator configures the attribute for Personalization in Search.
For the data model of this object, see the Search and Recommendation API reference.
In the following example, you want to:
-
Show personalized results for the keyphrase cloud.
-
Ask Sitecore Search to use the title and type of content when it searches for similar content. To do this, use the
fieldsarray within thepersonalizationobject and passtitleandtypeas values. -
Use the
affinityalgorithm to get personalized content.
The following code sample shows how to create a request:
{
"widget": {
"items": [
{
"rfk_id": "rfkid_7",
"entity": "content",
"search": {
"content": {},
"personalization": {
"fields": [
"title",
"type"
],
"algorithm": "affinity"
},
"limit": 10,
"offset": 0,
"query": {
"keyphrase": "cloud"
}
}
}
]
},
"context": {
"locale": {
"country": "us",
"language": "en"
},
"user": {
"uuid": "159871551-m7-17-44-1p-c0ya4nb69t8o0iho2eia-1667926756185"
}
}
}