Boosts

Boost results matching certain criteria without excluding non-matching results. Boosts must be created after Load() completes.

Creating Boosts

csharp
// BoostStrength enum: Low = 1, Med = 2, High = 3
Filter yearFilter = engine.CreateRangeFilter("year", 1980, 2025, out _)!;
Filter genreFilter = engine.CreateValueFilter("genre", "Documentary", out _)!;

var boosts = new List<Boost>();
Boost b = engine.CreateBoost(yearFilter & genreFilter, BoostStrength.Med);
Console.WriteLine(
quot;Documents boosted: {b.DocumentsBoosted}"); boosts.Add(b); query.Boosts = boosts.ToArray(); query.EnableBoost = true;

Personalized Boosting

For user-specific boosting across many items, OR per-item filters into one filter and boost it. item_id holds numbers, so each one is a range with equal limits: a value filter compares text and is refused on a numeric field.

csharp
Filter? frequentPurchases = null;
foreach (long itemId in userFrequentItemIds)
{
    Filter f = engine.CreateRangeFilter("item_id", itemId, itemId, out _)!;
    frequentPurchases = frequentPurchases is null ? f : frequentPurchases | f;
}

var userBoosts = new List<Boost>();
userBoosts.Add(engine.CreateBoost(frequentPurchases!, BoostStrength.Med));

query.Boosts = userBoosts.ToArray();
query.EnableBoost = true;

Applying a boost costs the same however many documents it covers: one check per scored result. Building a large per-user boost has its own cost, since every item in it is a filter.

Properties

NameTypeAccessDescription
BoostStrength
BoostStrength
get/set
Defines the boost strength.
DocumentsBoosted
int
get
Returns the number of documents boosted.
Filter
Filter
get/set
Filter which defines the set of documents to be boosted.

BoostStrengthenum

Defines the magnitude of the boost to be applied

NameValue
Low
1
Med
2
High
3