HomeGuidesAPI Reference
Submit Documentation FeedbackJoin Developer CommunityOptimizely GitHubOptimizely NuGetLog In

Boosting

Why and how we can use boosting of queries in Optimizely Content Graph.

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

Applications of boosting

Content Graph offers state-of-the-art relevance ranking out of the world, but allows you customization with query boosting. There can be business logic or domain-specific logic that will significantly improve the effectiveness of some queries. Matches on 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 will appear in the top of the SERP.

How does it work?

In the Where input argument of a GraphQL schema, we allow each predicate that you specify to be boosted with the boost operator option. This is of type Int, but we do not support negative boosting, so the value cannot be a negative number. By default, no boosting is applied in any predicate. Since boost is meant to influence the relevance ranking, it is recommended to project the relevance score with the _score field projection.

This is an example query with matching on content types, but where we 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
  }
}

And the response of the request would look like this, where we see that the media content types have indeed been 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"
  }
}