Using ranking

You can add custom ranking to change the relevancy of an item in the search results. To perform customized ranking, use the widget.items.search.ranking object and specify a name and weight.

Note

Before you can use an attribute for ranking, make sure that an administrator configures the attribute for Ranking in Search.

For the data model of this object, see the Search and Recommendation API reference.

For example, a visitor searches for product optimization and you have ten items in the results, each of which has a relevancy score. You can use customized ranking to increase or decrease the relevancy score of each item. If you rank by, say, review_rating, items with a greater review rating get a higher relevancy score.

Note

We recommend that you keep the weight to under five. This is to minimize the impact of a single attribute on the overall system.

The higher the weight, the more important Sitecore Search considers the attribute when it calculates the relevancy score. For example, if you want Sitecore Search to give slightly more importance to the review_rating attribute than to the genre attribute, pass both attributes and assign review_rating a higher weight.

The following code sample shows how to create a request:

RequestResponse
{
    "widget": {
        "items": [
            {
                "rfk_id": "rfkid_7",
                "entity": "content",
                "sources": [
                    "388218",
                    "390565"
                ],
                "search": {
                    "content": {
                        "fields": [
                            "title"
                        ]
                    },
                    "ranking": [
                        {
                            "name": "review_rating",
                            "weight": 1.7
                        }
                        {
                            "name": "genre",
                            "weight": 1.5
                        }
                    ]
                }
            }
        ]
    },
    "context": {
        "locale": {
            "country": "us",
            "language": "en"
        },
        "user": {
            "uuid": "159871551-1g-i4-4x-1p-f5tdhddqwvywv7b9g2vy-1664852644904"
        }
    }
}

Do you have some feedback for us?

If you have suggestions for improving this article,