TengenceTengence
Product docs

Search Ranking and Weighting Configuration

How pre-rank and rank work in Tengence Search, how to write formulas, the default and preset formulas, factor rules, plus validation, saving and rollback.

Ranking configuration decides who comes first after recall. Recall finds potentially relevant items, pre-rank quickly trims a larger candidate set, and rank scores the remaining candidates in more detail. The Ranking page puts these two stages in two tabs, but they share the same formula syntax, factor panel, function library and version management.

Weighting here is not about assigning an absolute quality score to every item. It combines several ranking signals into a comparable score for the current query. The score only orders candidates inside this request; weights do not have to sum to 1.

Where ranking sits in the search pipeline

A search request goes through three steps:

  1. Recall finds potentially relevant candidates from the index.
  2. Pre-rank applies a lightweight formula and keeps the top N candidates.
  3. Rank scores the remaining candidates with richer factors and decides the final order.

Pre-rank and rank are two stages of one ranking service, not two separate systems. If you configure rank but leave pre-rank empty, the service applies the default pre-rank formula and keeps 200 candidates, so rank never has to process the full recall set.

How pre-rank and rank divide the work

Item Pre-rank Rank
Goal Remove clearly unsuitable candidates and control cost Score a small candidate set and decide the final order
Input Recall candidates Candidates kept by pre-rank
Output Top N by formula score Final ranked list
Available factors Low-cost factors that support pre-rank All non-reserved factors
Default cutoff preRankTopN, default 200, range 1–5000 No cutoff
Typical signals Relevance, quality, title match, recall position, category, query features Relevance, quality, sales percentile, rating percentile, price percentile, freshness, semantic score

Hard rule: pre-rank only accepts factors whose stage includes pre-rank and whose cost is LOW. A MEDIUM or HIGH cost factor in pre-rank fails validation with FACTOR_STAGE_UNSUPPORTED.

Product guidance: sales, price and rating are better kept in rank even when some of them are technically low-cost and pass pre-rank validation. Pre-rank should only trim quickly; leave business weighting to rank so search latency stays predictable.

Formula basics

A formula is a single expression. Its result is the ranking score for one candidate.

  • System factors start with @, for example @relevance, @quality or @sales_percentile.
  • Plain fields use the exact field name from the index, for example title, price or stock.
  • The formula supports + - * / %, comparisons, if(condition, A, B) and the ternary operator.
  • Loops, assignment, regular expressions and string interpolation are not supported. = is assignment; use == to compare.
  • A formula can be up to 2000 characters, 16 levels of parentheses and 30 factor/field references. More than 12 references triggers a performance warning.

A minimal usable formula:

0.6 * @relevance + 0.3 * @quality + 0.1 / @recall_position

The numbers are weights and the @ names are system factors. Multiplication must be explicit, and the denominator must not be zero.

Writing a pre-rank formula

The default pre-rank formula is:

0.6 * @relevance + 0.3 * @quality + 0.1 / @recall_position

Relevance carries 60%, content quality 30%, and recall position only 10% as a mild order prior. @recall_position starts at 1 for the first recalled item; larger values mean lower positions. That is why the formula uses 1 / @recall_position, not the raw position.

preRankTopN defaults to 200 and accepts 1–5000. It only controls how many candidates pre-rank passes to rank. A larger value reduces the chance of cutting a good result too early, but increases rank cost and search latency. Start with 200 unless you have a specific reason.

The console ships with eight pre-rank presets:

Preset Formula When to use
General 0.6 * @relevance + 0.25 * @quality + 0.15 * @title_match General product or content search
Relevance first 0.7 * @relevance + 0.2 * @quality + 0.1 * @category_match Relevance matters most and categories are focused
Recall position 0.6 * @relevance + 0.3 * @quality + 0.1 / @recall_position Recall quality is stable and original order should be preserved
Title match 0.65 * @relevance + 0.25 * @title_match + 0.1 * @quality The title is the main signal
Category consistency 0.55 * @relevance + 0.2 * @category_match + 0.15 * @category_confidence + 0.1 * @quality Category intent is clear and cross-category results should be reduced
Query terms 0.6 * @relevance + 0.15 * @quality + 0.15 * @title_match + 0.1 * saturate(@term_count, 5) Long or multi-term queries
Brand query 0.55 * @relevance + 0.2 * if(@is_brand_query, 1, 0) + 0.15 * @title_match + 0.1 * @quality Brand searches
Long query 0.55 * @relevance + 0.2 * @quality + 0.15 * @title_match + 0.1 * saturate(@query_len, 20) Long query strings
Pre-rank configuration in the Tengence console
Figure 1. The pre-rank tab on the Ranking page, with the stage switch on the left and the system factor panel on the right.

The left side switches stages, the right side is the factor panel, and the formula editor sits in the middle with validation and save actions below.

Writing a rank formula

The default rank formula is:

0.35 * @relevance
+ 0.25 * @quality
+ 0.15 * @sales_percentile
+ 0.10 * @rating_percentile
+ 0.10 * @price_percentile
+ 0.05 * @freshness

Relevance and quality are the main signals. Sales, rating and price percentiles add business weighting, and 5% freshness provides a light recency correction. Percentiles and z-scores are computed inside the current candidate set, so they change when the query or candidate set changes.

Rank can use all non-reserved factors, which makes it the right place for sales, price, rating, stock, freshness and semantic match. Ten rank presets are available:

Preset Formula When to use
General 0.5 * @relevance + 0.25 * @quality + 0.15 * @freshness(update_time, 30) + 0.1 * @has_image General blended ranking
In stock first 0.6 * @relevance + 0.2 * @in_stock + 0.1 * @rating_percentile + 0.1 * (1 / @recall_position) Out-of-stock is the main negative experience
New items 0.55 * @relevance + 0.25 * @freshness(update_time, 14) + 0.2 * @quality Frequent launches and time-sensitive inventory
Price sensitive 0.5 * @relevance + 0.2 * (1 - @price_percentile) + 0.15 * @rating_percentile + 0.15 * @sales_percentile Price is a core decision factor
Content quality 0.45 * @relevance + 0.2 * @title_match + 0.15 * @content_match + 0.1 * @quality + 0.1 * clamp(@title_len / 60, 0, 1) Content sites, news and long-form pages
Stock depth 0.55 * @relevance + 0.2 * saturate(@stock, 20) + 0.15 * @rating_percentile + 0.1 * @freshness(update_time, 30) Inventory depth affects fulfillment
Semantic match 0.6 * @semantic + 0.25 * @relevance + 0.15 * @category_match Semantic search and long-tail queries
Time decay 0.6 * @relevance + 0.25 * decay(@new_days, 30) + 0.15 * @rating_percentile Strong recency requirements
Average quality 0.4 * @relevance + 0.3 * avg(@quality, @rating_percentile) + 0.3 * @freshness(update_time, 30) Quality signals need mutual calibration
Title keyword 0.55 * @relevance + 0.2 * if(contains(lower(title), "iphone"), 1, 0) + 0.25 * @quality A strong keyword intervention is needed
Rank configuration in the Tengence console
Figure 2. The rank tab on the same page; pre-rank and rank keep separate versions.

Rank and pre-rank share the same editor. After switching tabs, each stage keeps its own formula and version.

How to use system factors

System factors are signals the ranking service computes for you; you do not need SQL or a script. There are 32 factors in five groups:

  • Upstream scores: relevance, quality, recall position, title match, content match, category match, semantic score.
  • Product and content derived: sales, rating, review count, price, discount, in-stock, stock, days since creation, freshness, main image, image count, title length.
  • Candidate-set statistics: sales percentile, rating percentile, price percentile, price z-score, sales z-score.
  • Query-side: query length, term count, category confidence, brand-query flag.
  • Reserved and unavailable: CTR, CVR, user preference match, stockout risk.

Recommended order:

  1. Check the stage. Pre-rank only takes low-cost factors that support pre-rank. Percentiles, z-scores, freshness and semantic match are rank-only.
  2. Check the binding. A factor that depends on a semantic tag evaluates to 0 when that tag is not bound. Validation shows FACTOR_NOT_BOUND but does not block saving.
  3. Check the scale. Sales, price, stock and review count are raw values. Apply saturate, log1p or a percentile before multiplying by a weight.
  4. Check the count. More factors is not better. More than 12 references triggers a performance warning; keep the strongest signals.
  5. Do not use reserved factors. @ctr, @cvr, @user_pref_match and @stockout_risk are not available and fail validation with FACTOR_NOT_AVAILABLE.

See the Ranking Factors and Functions Reference for each factor’s meaning, dependency, stage and cost.

How to use semantic fields

A semantic tag gives an index field a business meaning, so the service knows which field is price, sales or creation time. Ranking factors bind to those semantic tags.

For example:

  • Mark the price field as PRICE to make @price, @price_percentile and @z_price available.
  • Mark the sales field as SALES_COUNT to make @sales, @sales_percentile and @z_sales available.
  • Mark the creation time as CREATE_TIME to let @new_days and @freshness bind automatically.

A semantic tag can be bound to more than one field. The service uses the first field in the candidate list. Keep one primary field per tag so the ranking does not depend on field order.

Common handling rules:

Semantic tag Avoid Recommended Example
PRICE Multiplying raw price with a large weight Use the inverse price percentile for low-price preference, or compress first 0.2 * (1 - @price_percentile)
SALES_COUNT Multiplying raw sales in the tens of thousands Percentile, saturate or log1p 0.15 * @sales_percentile
RATING Treating 4.8 as a 0–1 value Normalize by the rating ceiling or use a percentile 0.1 * clamp(@rating / 5, 0, 1)
REVIEW_COUNT Multiplying the raw review count saturate or log1p 0.1 * saturate(@review_count, 50)
STOCK Multiplying raw stock @in_stock for availability; saturate for depth 0.2 * @in_stock
CREATE_TIME / UPDATE_TIME Arithmetic on raw timestamps @freshness, @new_days or decay 0.25 * @freshness(update_time, 30)
Semantic fields panel in the Tengence console
Figure 3. Semantic fields bound to the current app, with their semantic tags.

The panel lists the fields and semantic tags bound to the current app. In this screenshot only category, description, product_id, price, rating and title are bound, so sales, stock and freshness factors show as unbound.

How to use plain fields

Plain fields are index fields without a semantic tag. They can appear in formulas, but they do not bind to system factors automatically.

  • Numeric fields can be multiplied directly, but compress large ranges first, for example log1p(sales) or clamp(price / 1000, 0, 1).
  • Text fields cannot be multiplied. Use text predicates or length, for example contains(lower(title), "iphone") or length(title).
  • Date and time fields must not be used in arithmetic; they produce values in the billions. Convert them with @freshness(field, days) or @new_days. Direct arithmetic fails with TYPE_MISMATCH.
  • Boolean fields usually return 0 or 1 and can take a weight directly.
  • Array fields such as IMAGE_LIST should use @image_count; do not do arithmetic on the array itself.
  • Missing values: system factors default to 0. For plain fields use default(field, fallback). A field that is not in the index schema triggers FIELD_UNVERIFIED and evaluates to 0.

Validation, saving, versions and rollback

Recommended sequence:

  1. Write the formula in the pre-rank or rank tab.
  2. Click Validate formula and read errors first, then warnings and cost hints.
  3. Fix errors such as FACTOR_STAGE_UNSUPPORTED, UNKNOWN_FACTOR and TYPE_MISMATCH.
  4. Review warnings such as FACTOR_NOT_BOUND, FIELD_UNVERIFIED and MANY_FACTORS.
  5. Save as a draft, or save and activate immediately.
  6. Check the ACTIVE version in version history and roll back if needed.

Saving rules:

  • Pre-rank and rank save independently, with separate versions.
  • Version states are DRAFT, ACTIVE and ARCHIVED.
  • Activating a new version archives the previous one; two versions never run at the same time.
  • Version history supports loading an old version, reactivating it, and restoring the default formula.
  • Saving a draft does not affect production. Only an ACTIVE version takes effect.

Validation passing does not guarantee better results. Before launch, compare old and new formulas on the same query set and watch relevance, clicks, conversion and search latency, not a single example.

FAQ

Can pre-rank use sales, price or rating?

Some product factors are low-cost and pass pre-rank validation, but product guidance is still to keep them in rank. Pre-rank exists to trim quickly, not to apply full business weighting. Putting sales, price and rating in pre-rank increases cost and can cut candidates that rank would have weighted up.

What does “no bound field” mean?

The app has not bound the semantic tag that the factor depends on. Add the field and tag in the index schema, or use another factor. It is a warning, not an error; the factor evaluates to 0 at runtime.

Why does a time field fail when multiplied?

Arithmetic on a timestamp produces a value in the billions, not a usable score. Validation reports TYPE_MISMATCH. Use @freshness(update_time, 30), decay(@new_days, 30) or @new_days.

The formula was saved but nothing changed.

Check the version state. A draft does not affect production. Activate the version in version history, or save with immediate activation.

The formula is too long or too deeply nested.

Split it into simpler intermediate terms and remove low-impact factors. Limits are 2000 characters, 16 parenthesis levels and 30 factor/field references; more than 12 references triggers a performance warning.

Why are the score gaps so small?

One raw-value factor may be dominating the others. Normalize sales, price, stock and review count first, and keep all factors roughly comparable on a 0–1 scale before tuning the ratios.

For every factor definition, dependency, stage and cost, continue with the Ranking Factors and Functions Reference.

On this page