HomeDev guideRecipesAPI ReferenceGraphQL
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 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. Poorly configured site or e-commerce search performs poorly in terms of not only conversation rates, but a deficit in engagement and general trust in the site as whole.

Applications of boosting

Optimizely Graph offers relevance ranking out of the world, 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 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 appear in the top of the SERP.

How does it work?

In the Where input argument of a GraphQL schema, allow each predicate that you specify 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. By default, no boosting is applied in any predicate. Since 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"
  }
}