RecomNext
FeaturesHow it WorksWhy RecomNextResourcesGet Started

nextQL Guide

nextQL is RecomNext's purpose-built query language for filtering, boosting, and segmenting recommendation candidates at request time.


What is nextQL?

nextQL lets product owners define per-scenario filter and booster expressions that the recommendation engine evaluates at request time against the candidate item set. It also supports segmentation expressions that compute dynamic segment membership for each item.

Filter Syntax

Filters return only items whose attributes satisfy the condition. Attributes are referenced by quoted name.

ElementSyntaxExample
AttributeQuoted string'price', 'category'
Comparisonattribute op value'price' < 100
Operators= != < <= > >= in not_in'status' != 'discontinued'
Array[val1, val2, ...]'category' in ['a', 'b']
Andexpr and expr'price' < 100 and 'stock' > 0
Orexpr or expr'onSale' = true or 'price' < 20
Grouping(expr)('a' = 1 or 'b' = 2) and 'c' > 0
Examples
// Electronics under $150
'category' = 'electronics' and 'price' < 150

// Highly rated books
'category' = 'books' and 'rating' > 4.5

// Items in specific categories
'category' in ['clothing', 'sports', 'electronics']

// In stock and not discontinued
'stock' > 0 and 'status' != 'discontinued'
Booster Syntax

Boosters multiply the score of matching items. Each booster is a single expression on its own line.

boost by <factor> where <filter_expression>

// factor: any positive number (1.0 = no change)
// condition: same syntax as filter expressions
Examples
boost by 2.0 where 'featured' = true
boost by 1.5 where 'category' = 'electronics'
boost by 1.3 where 'price' < 30
boost by 0.5 where 'stock' < 5
Segmentation Expressions

Used in auto-nextQL segmentations. These expressions evaluate against each item and return a set of segment names the item belongs to.

ElementSyntaxDescription
Attribute (set)'attributeName'Returns the attribute's values as a set
Set literal{"val1", "val2"}Creates an explicit set
Empty set{}Empty set (no segments)
Set unionexpr + exprCombines two sets
Conditionalif <cond> then <expr> else <expr>Conditional branching based on attribute
Map / Lambdamap(lambda 'x': <body>, <collection>)Transform each element of a collection
String convertstring('attr')Convert attribute value to string
Date formatstring('attr', '%Y-%m')Format date with tokens: %Y, %m, %d
Grouping(expr)Parentheses for precedence
Examples
// Group by genres + conditional tag
'genres' + (if 'critically_acclaimed'
  then {"Critically Acclaimed"} else {})

// Price-tier segmentation
if 'price' < 20 then {"Budget"}
  else (if 'price' > 100 then {"Premium"}
  else {"Mid-Range"})

// Transform dates into month buckets
map(lambda 'x': {string('created', '%Y-%m')},
  'category')

// Combine category with brand
'category' + 'brand'
Attribute Resolution

Attributes are resolved from the item's top-level fields first (e.g., category), then from a nested attributes object. Array-valued attributes are automatically unwound into individual set members in segmentation expressions.