HomeDev guideAPI Reference
Dev guideUser GuideGitHubNuGetDev CommunitySubmit a ticketLog In
GitHubNuGetDev CommunitySubmit a ticket

Boosting

Describes why and how to use boosting of queries in Optimizely Graph.

Optimizely Graph offers access to your data with a search engine. Relevance ranking is a crucial feature that search engines support, besides the fast retrieval performance. The most relevant results for a given query in a search engine result page (SERP) should be ranked higher than the less relevant ones, and the most relevant results should be ranked at the top. Offering customization in tweaking and tuning relevance ranking can be beneficial in improving the effectiveness of searches. Web users expect search engines to be effective. Poorly configured site or ecommerce search performs poorly in terms of not only conversation rates but a deficit in engagement and general trust in the site.

Applications of boosting

Optimizely Graph offers relevance ranking out of the box and gives you customization with query boosting. There can be business logic or domain-specific logic that significantly improves the effectiveness of some queries. Matches in some fields may be more relevant than others.

Another application with boosting is implementing sponsored search. Given certain matching terms in the query, you may want to expand the query with some IDs of documents (certain pages or products) so these documents display at the top of the SERP.

How does it work?

In the Where input argument of a GraphQL schema, you specify each predicate that you want to be boosted with the boost operator option. This is of type Int, but Optimizely Graph does not support negative boosting, so the value cannot be a negative number. If the value of a boost is null, then no boosting is applied.

By default, no boosting is applied in any predicate. Because boost is meant to influence the relevance ranking, you should project the relevance score with the _score field projection.

The following example shows a query with matching on content types, but where you want to boost the media types to the top of the results.

{
  Content(
    locale: en,
    limit: 5,
    where: {
      _or: [
        {
          ContentType: {
            eq: "Content"
          }
        },
        {
          ContentType: {
            eq: "Media", 
            boost: 10
          }
        }
      ]
    }
  ) {
    items {
      ContentType
      _score
    }
    total
  }
}

Response

The media content types are boosted to the top.

{
  "data": {
    "Content": {
      "items": [
        {
          "ContentType": [
            "Image",
            "Media",
            "ImageFile",
            "Content"
          ],
          "_score": 149.00687
        },
        {
          "ContentType": [
            "Image",
            "Media",
            "ImageFile",
            "Content"
          ],
          "_score": 149.00687
        },
        {
          "ContentType": [
            "Image",
            "Media",
            "ImageFile",
            "Content"
          ],
          "_score": 149.00687
        },
        {
          "ContentType": [
            "Page",
            "StandardPage",
            "Content"
          ],
          "_score": 0.05333282
        },
        {
          "ContentType": [
            "Page",
            "StandardPage",
            "Content"
          ],
          "_score": 0.05333282
        }
      ],
      "total": 50
    }
  },
  "extensions": {
    "correlationId": "83b98f1c-b3d8-4719-a3ec-b484504c1f4e"
  }
}