Dev guideRecipesAPI ReferenceChangelog
Dev guideRecipesUser GuidesNuGetDev CommunityOptimizely AcademySubmit a ticketLog In
Dev guide

Boosting

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

Boosting in Optimizely Graph is a way to tell the search engine that certain documents or fields are more important than others, so they rank higher in the search engine results page (SERP). Use boosting to apply business logic, surface sponsored content, or weight some fields above others in relevance ranking. Customization in tweaking and tuning relevance ranking improves the effectiveness of searches, because poorly configured site or ecommerce search performs poorly in terms of conversion rates, engagement, and general trust in the site.

Applications of boosting

Apply boosting in two common scenarios: enforcing business or domain logic on relevance ranking, and implementing sponsored search. Both let you override the default ranking when a specific reader experience is more valuable than pure relevance.

Optimizely Graph offers relevance ranking and gives you customization with query boosting. Business logic or domain-specific logic can significantly improve the effectiveness of some queries. Matches in some fields are more relevant than others.

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

How boosting works

Optimizely Graph supports three boosting techniques: regular boost on predicates, Gaussian decay on datetime fields, and numeric factors on number fields. Use the technique that matches the signal you want to amplify in the ranking.

Regular boost

In the Where input argument of a GraphQL schema, 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, 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"
  }
}

Boost datetime fields with a Gaussian function

Prioritize recent results by applying a greater boost using a Gaussian function. Example use cases include the following:

  • Giving pages that are more recently published a higher score.
  • Ranking biographies of people who were born closer to a specific date higher.

It is called a decay function because the greater the distance from the origin, the lower the weight becomes. It becomes a decay curve. In the Optimizely Graph query language, add decay to a field used in the where input types, which accepts three parameters:

  • origin – The origin of the date with optional time where the top of the curve (central point) starts.
    • Defaultnow()
  • scale – The rate of decay in days.
    • Default – 1,000.
  • rate – Defines how documents are scored at the distance given a rate of decay.
    • Default – 0.5.

Example

{
    BiographyPage(
      orderBy: { _ranking: SEMANTIC }
      where: { Born: { decay: { origin: "1990-01-01", scale: 10000, rate: 0.3 } } }
  ) {
    total
    items {
      _score
      Born
    }
  }
}

Influence scores with numeric values

Use numeric factors when a field like clicks, upvotes, or inventory count carries useful ranking signal. The result is a personalized ranking that mixes relevance with dynamic metadata, so the most relevant and most popular items rank together at the top.

Influence the score based on number fields of type Float and Int. Use numeric factors for dynamic metadata with dimensions like "number of clicks", "number of upvotes", or "number in inventory", or for business logic like prioritization of pages.

Do not order purely by these dimensions. Combine them with other ranking dimensions like similarity of query and content, time with a decay function (see the previous section), the language of the query, or location of the user. The calculations of the ranking are represented with the _score field. When you have a mixture of these dimensions, you can implement personalized content delivery (search).

No one-size-fits-all approach to tweaking and tuning the ranking on your data and queries exists. Test carefully, for example with an offline test with a set of queries.

Influence the score in Optimizely Graph by adding the factor operator in a number field. It has two properties that can be set:

  1. value (float) – The factor that is multiplied with the number in a field. By default this is 1.0 and it cannot be a negative number.
  2. modifier – Has the following enumeration:
    1. NONE (default) – Do not apply any multiplier to the field value.
    2. SQUARE – Square the field value (multiply it by itself).
    3. SQRT – Take the square root of the field value.
    4. LOG – Add 1 to the field value and take the natural logarithm.
    5. RECIPROCAL – Reciprocate the field value, same as 1/x where x is the value of the field.

If a field consists of an array with multiple numbers, then the lowest number is used.

Example

This GraphQL query shows how to influence score by the number of clicks.

{
  BiographyPage(
    locale: en
    orderBy: { _ranking: SEMANTIC }
    where: {
      _fulltext: { match: "female actor newton amy" }
      NumClicks: { gt: 1, factor: { value: 10, modifier: SQRT } }
    }
  ) {
    total
    items {
      _score
      _fulltext
      NumClicks
    }
  }
}

It returns the following results, which show the impact of the value of NumClicks on the _score in combination with semantic search. The item with the most clicks gets ranked to the top, but does not totally override the weight of the relevance scoring, as subsequent items show.

{
  "data": {
    "BiographyPage": {
      "total": 4,
      "items": [
        {
          "_score": 235.25735,
          "_fulltext": [
            "Alan Turing"
          ],
          "NumClicks": 5435
        },
        {
          "_score": 230.35423,
          "_fulltext": [
            "Test CharacterName",
            "This is a quote content",
            "Amy Winehouse",
            "5",
            "1",
            "10"
          ],
          "NumClicks": 1001
        },
        {
          "_score": 112.84823,
          "_fulltext": [
            "Marie Curie"
          ],
          "NumClicks": 1234
        },
        {
          "_score": 104.785904,
          "_fulltext": [
            "Arnold Schwarzenegger",
            "3",
            "7",
            "12"
          ],
          "NumClicks": 999
        }
      ]
    }
  }
}