Complete reference for Tengence Search ranking: 32 system factors, semantic field handling, plain-field rules, functions, and validation errors.
This is the reference companion to Search Ranking and Weighting Configuration. It is organized for lookup: all 32 system factors first, then semantic fields, plain fields, the function library, stage and cost rules, and validation errors.
There are 32 system factors in five groups. Each factor lists its available stage and cost:
Pre-rank + rank: low-cost factors usable in both stages.
Rank only: medium-cost factors; pre-rank validation fails with FACTOR_STAGE_UNSUPPORTED.
Reserved: registered but unavailable; validation fails with FACTOR_NOT_AVAILABLE.
Upstream scores
Factor
Meaning
Semantic dependency
Stage
Cost
Typical use
@relevance
Upstream relevance score summarizing how well the item matches the query.
—
Pre-rank + rank
Low
The base term in most formulas; usually carries the largest weight.
@quality
Upstream content quality score covering title, body and images.
—
Pre-rank + rank
Low
Pair with relevance to keep highly relevant but low-quality items from ranking first.
@recall_position
Position of the item in the recall result, starting at 1; larger means lower.
—
Pre-rank + rank
Low
Use 1 / @recall_position as a mild order prior; never multiply the raw position with a positive weight.
@title_match
Title match score for query terms found in the title.
—
Pre-rank + rank
Low
Useful when title relevance should lead; combine with relevance and quality.
@content_match
Body match score for query terms found in the content.
—
Rank only
Medium
Rank-only; adds signal when the title does not cover the query.
@category_match
Category match score between the query intent category and the item.
—
Pre-rank + rank
Low
Weights category consistency and reduces cross-category results.
@semantic
Semantic similarity score from a vector or semantic model.
—
Rank only
Medium
For semantic and long-tail queries; rank-only.
Product and content derived
Factor
Meaning
Semantic dependency
Stage
Cost
Typical use
@sales
Raw sales count from the SALES_COUNT semantic field.
SALES_COUNT
Pre-rank + rank
Low
Smooth or convert to a percentile first; never multiply raw counts with a weight.
@rating
Raw rating value from the RATING semantic field.
RATING
Pre-rank + rank
Low
Normalize by the rating ceiling, e.g. @rating / 5, or use @rating_percentile.
@review_count
Raw review count from the REVIEW_COUNT semantic field.
REVIEW_COUNT
Pre-rank + rank
Low
Compress the long tail with saturate or log1p; do not multiply the raw count.
@price
Raw price from the PRICE semantic field.
PRICE
Pre-rank + rank
Low
For low-price preference use 1 – @price_percentile; compress with saturate(@price, p) or log1p(@price).
@discount
Discount rate in 0–1. Reads the discount field first; percentages above 1 are divided by 100; otherwise computes 1 – price / original_price.
DISCOUNT
Pre-rank + rank
Low
Already in 0–1, so it can take a small direct weight.
@in_stock
In-stock flag: 1 when stock is above 0, otherwise 0.
STOCK
Pre-rank + rank
Low
Use for a hard in-stock preference or a large baseline weight.
@stock
Raw stock quantity from the STOCK semantic field.
STOCK
Pre-rank + rank
Low
Compress to 0–1 with saturate(@stock, p); do not multiply the raw value.
@new_days
Days since creation, bound to the CREATE_TIME semantic field.
CREATE_TIME
Rank only
Medium
Use decay(@new_days, 30) for time decay, or compare with a threshold.
@freshness
Freshness in 0–1 with half-life decay; 30 days by default, or @freshness(update_time, 30).
CREATE_TIME
Rank only
Medium
Weights new or time-sensitive content; an upstream freshness_score is used first when present.
@has_image
Has main image flag: 1 when present, otherwise 0.
MAIN_IMAGE_URL
Pre-rank + rank
Low
For an image-present preference, usually with a small weight.
@image_count
Number of images counted from a comma-separated list; 0 when missing.
IMAGE_LIST
Rank only
Medium
Use saturate(@image_count, p) before applying a small weight.
@title_len
Title character count; 0 when missing.
TITLE
Rank only
Medium
Use clamp(length(title) / 60, 0, 1), or filter out very short titles.
Candidate-set statistics
Factor
Meaning
Semantic dependency
Stage
Cost
Typical use
@sales_percentile
Sales percentile within the current candidate set, 0–1.
SALES_COUNT
Rank only
Medium
More stable than raw sales when comparing across categories.
@rating_percentile
Rating percentile within the current candidate set, 0–1.
RATING
Rank only
Medium
Gives ratings a comparable weight across the candidate set.
@price_percentile
Price percentile within the current candidate set, 0–1.
PRICE
Rank only
Medium
For low-price preference use 1 – @price_percentile instead of multiplying price.
@z_price
Price z-score using the current candidate mean and population standard deviation.
PRICE
Rank only
Medium
Detects price outliers; sensitive to extremes, so use negative weights carefully.
@z_sales
Sales z-score using the current candidate mean and population standard deviation.
SALES_COUNT
Rank only
Medium
Detects sales outliers; extreme values have a large effect.
Query-side
Factor
Meaning
Semantic dependency
Stage
Cost
Typical use
@query_len
Character length of the query string.
—
Pre-rank + rank
Low
Use saturate(@query_len, 20) to express long-query intent.
@term_count
Number of effective query terms; stop-word-filtered tokens when available, otherwise total terms.
—
Pre-rank + rank
Low
Use saturate(@term_count, 5) with a small weight.
@category_confidence
Confidence of the first category in the query intent, 0–1.
—
Pre-rank + rank
Low
When category intent is clear, increase the weight of @category_match.
@is_brand_query
Whether the query hits a brand or organization entity: 1 or 0.
—
Pre-rank + rank
Low
For brand queries, raise the weight of relevance or title match.
Reserved and unavailable
Factor
Meaning
Semantic dependency
Stage
Cost
Typical use
@ctr
Click-through rate; reserved and unavailable.
—
Rank only
Medium
Not available yet.
@cvr
Conversion rate; reserved and unavailable.
—
Rank only
Medium
Not available yet.
@user_pref_match
User preference match; reserved and unavailable.
—
Rank only
High
Not available yet.
@stockout_risk
Stockout risk; reserved and unavailable. It is computed in code but registered as RESERVED, so validation reports it as unavailable.
STOCK
Rank only
Medium
Use @in_stock instead.
Figure 1. System factors grouped by source, each with its computation cost.
The factor panel groups factors by source and shows the cost of each one. Factors whose semantic fields are not bound in the current app are marked separately and evaluate to 0 in a formula.
Semantic fields and handling
Semantic tags connect business fields to system factors. A tag can bind more than one field; the service uses the first field in the candidate list, so keep one primary field per tag. If no field is bound, the dependent factor evaluates to 0, and validation shows FACTOR_NOT_BOUND.
Semantic tag
Field meaning
Related factors
Recommended handling
Example
TITLE
Title text
@title_len
Normalize by character count, or use it only for length filtering
clamp(length(title) / 60, 0, 1)
DESCRIPTION
Description or body
@content_match
Never multiply text; use content match or contains for a predicate
contains(lower(description), "organic")
CATEGORY_NAME
Category name
@category_match
Use the upstream category score; use text only as a helper
0.15 * @category_match
PRICE
Price
@price, @price_percentile, @z_price
Use 1 - percentile for low-price preference; compress raw values
0.2 * (1 - @price_percentile)
RATING
Rating
@rating, @rating_percentile
Normalize by the rating ceiling or use a percentile
0.1 * clamp(@rating / 5, 0, 1)
SALES_COUNT
Sales count
@sales, @sales_percentile, @z_sales
Percentile, saturate or log1p
0.15 * @sales_percentile
REVIEW_COUNT
Review count
@review_count
saturate or log1p
0.1 * saturate(@review_count, 50)
STOCK
Stock
@stock, @in_stock, @stockout_risk
Use the 0/1 flag for availability; saturate for depth
0.2 * @in_stock
DISCOUNT
Discount rate
@discount
Already 0–1; a small direct weight is fine
0.05 * @discount
CREATE_TIME
Creation time
@new_days, @freshness
Do not multiply; use days or half-life
0.25 * decay(@new_days, 30)
UPDATE_TIME
Update time
@freshness
Must pass the field explicitly; no automatic binding
0.25 * @freshness(update_time, 30)
MAIN_IMAGE_URL
Main image URL
@has_image
Use the 0/1 flag for an image preference
0.1 * @has_image
IMAGE_LIST
Image list
@image_count
Compress the count before applying a small weight
0.05 * saturate(@image_count, 5)
ID
Primary key
—
Never use it as a score
Keep it out of formulas
Common mistakes:
PRICE, SALES_COUNT and STOCK have large raw ranges. A direct weight lets one factor dominate everything else.
RATING is usually 0–5; do not treat it as a 0–1 value.
CREATE_TIME binds automatically to @new_days and @freshness. UPDATE_TIME does not; write @freshness(update_time, 30) explicitly.
Percentiles and z-scores are computed within the current candidate set, not across the whole index. The same item can get a different value when the candidate set changes.
@stockout_risk is reserved and unavailable. Use @in_stock for availability.
Plain fields
Plain fields are index fields without a semantic tag. They can appear in formulas, but you must control their type and scale.
length, contains, starts_with, ends_with, lower, upper, trim, or only inside an if condition
Date/time
No
Convert with @freshness(field, days), @new_days or decay
Boolean
Yes
Multiply 0/1 directly, or use it in if
Array
No
Use @image_count for image lists; convert other arrays to a number first
Missing value
Depends
System factors default to 0; use default(field, fallback) for plain fields
A field that is not in the index schema triggers a FIELD_UNVERIFIED warning and evaluates to 0. Arithmetic on text or date/time fields fails with TYPE_MISMATCH; time fields also get a hint to use freshness or days since creation.
Function library
The console function panel has 24 entries grouped by condition, normalization, time, math and text. The table below marks which functions are visible in the console and which are backend-only.
Condition and null handling
Function
Signature
Meaning
Example
Availability
if
if(condition, A, B)
条件判断,条件为真返回 A,否则返回 B。
if(@in_stock, 1, 0)
Console
default
default(value, fallback)
值缺失或为空时返回兜底值。
default(@rating, 3)
Console
exists
exists(value)
值存在返回 1,否则 0。
exists(@discount)
Console
iif
iif(condition, A, B)
后端支持的 if 别名;控制台统一用 if。
iif(@in_stock, 1, 0)
Backend
Normalization
Function
Signature
Meaning
Example
Availability
clamp
clamp(x, lo, hi)
把 x 限制在 [lo, hi];等价于 min(max(x, lo), hi)。
clamp(@rating / 5, 0, 1)
Console
sigmoid
sigmoid(x, center)
S 形归一化,1 / (1 + e^-(x-center)),输出 0–1;center 是中心点。
Figure 2. The function library grouped by condition, normalization, math and text.
Key details:
clamp(x, lo, hi) limits a value to a range; it does not normalize to 0–1. For 0–1 use clamp(x, 0, 1) or sigmoid.
saturate(x, p) is saturation, not a linear scale. p is the half-saturation point: x = p gives 0.5, and the result approaches 1 without reaching it.
sigmoid(x, c) is an S-shaped normalization with center c. x = c gives 0.5, which is useful for mapping any range to 0–1.
decay(age, halfLife) halves the value after halfLife; keep age and halfLife in the same time unit.
log is natural log and log10 is base 10. For long-tailed sales and review counts, log1p is safer because log1p(0) = 0.
Both min() and max() are supported. The console’s “min/max” entry inserts a max(, ) template by default; change the function name to min when you need the smaller value.
Text comparisons are case-sensitive. Apply lower() first when case should be ignored, for example contains(lower(title), "iphone").
Stage and cost rules
Factor group
Pre-rank
Rank
Cost range
Notes
Upstream scores
All except @content_match and @semantic
All
Low–medium
Relevance, quality, recall position and title/category match are the pre-rank workhorses
Product and content derived
Sales, rating, review count, price, discount, in-stock, stock, main image; days since creation, freshness, image count and title length are rank-only
All
Low–medium
Compress raw values; time factors are rank-only
Candidate-set statistics
Not available
All
Medium
Depend on the current candidate set, which is not stable during pre-rank
Query-side
All
All
Low
Lightweight and useful for intent preservation in pre-rank
Reserved
Not available
Not available
Medium–high
Validation fails with FACTOR_NOT_AVAILABLE
The hard pre-rank rule is “stage supported + cost LOW”. Some product factors are low-cost and pass validation, but product guidance still keeps them in rank: pre-rank trims, rank applies business weighting.
Validation errors
Code
Cause
Fix
FORMULA_EMPTY
Formula is empty
Write a formula or click Restore default
FORMULA_TOO_LONG
More than 2000 characters
Remove low-impact factors and split the expression
TOO_COMPLEX
More than 16 parenthesis levels, or more than 30 references
Reduce nesting and compute intermediate terms first
UNSUPPORTED_SYNTAX
Loop, assignment, regex or string interpolation
Use a single expression; compare with ==
UNSUPPORTED_FUNCTION
Function outside the library
Pick one from the function tab, or use if, clamp or saturate
SYNTAX_ERROR
Unbalanced parentheses, missing operator or comma
Check parentheses, commas and operators
UNKNOWN_FACTOR
Unknown @ factor
Pick from the factor panel and check spelling
FACTOR_STAGE_UNSUPPORTED
Rank-only factor or medium/high-cost factor in pre-rank
Use a low-cost factor in pre-rank; keep it in rank
FACTOR_NOT_AVAILABLE
Reserved factor
Remove it or use an available factor
UNKNOWN_FIELD
Explicit field argument is not in the current index
Check the field name and pick from the field panel
TYPE_MISMATCH
Text or date/time field used in arithmetic
Use text only in predicates; convert time with @freshness or @new_days
FACTOR_NOT_BOUND (warning)
The app has not bound the semantic tag
Add the field and tag, or use another factor; runtime value is 0