Rules
Reusable filter, booster, and constraint bundles attached to scenarios via rulesSlugs. Avoid duplicating the same nextQL across many placements.
Rule types
| Setting | Type | Default | Description |
|---|---|---|---|
| filter | rule type | — | nextQL filter expression — excludes candidates. |
| booster | rule type | — | nextQL booster expression — adjusts scores. |
| constraint | rule type | — | constraintsConfig object — merges into scenario constraints. |
Rule settings
| Setting | Type | Default | Description |
|---|---|---|---|
| slug | string | — | Unique per tenant; referenced in rulesSlugs. |
| expression | string | — | nextQL for filter/booster types. |
| constraintsConfig | object | — | For constraint type — same fields as scenario constraints. |
| priority | number | 0 | Higher priority rules applied first. |
| active | boolean | true | Inactive rules are skipped. |
Examples
Use case
Global in-stock rule
POST /rules
{
"name": "In stock only",
"slug": "in-stock",
"type": "filter",
"expression": "'stock' > 0",
"priority": 100,
"active": true
}Use case
Boost featured products
{
"name": "Boost featured",
"slug": "boost-featured",
"type": "booster",
"expression": "boost by 1.5 where 'featured' = true",
"priority": 50
}Use case
Shared diversity constraint
{
"name": "Homepage diversity",
"slug": "homepage-diversity",
"type": "constraint",
"constraintsConfig": {
"maxPerCategory": 2,
"longTailPercentage": 15,
"injectLongTail": true
}
}Attach to scenario
{
"slug": "pdp-related",
"logicType": "item-to-item",
"rulesSlugs": ["in-stock", "boost-featured"],
"filter": "'category' = 'pc'"
}Merge order: rules (by priority) → scenario filter → rule + scenario boosters → merged constraints. See Scenarios — processing order.
