Course contents

Business ranking

Add popularity and freshness while preserving textual relevance.

5 sectionsElasticsearch 9.4.3Not read yet

What you will learn

  • Candidates and preferences
  • Functions and normalization
  • Scripts and a second stage

Add popularity and freshness while preserving textual relevance.

course-products examples use the teaching mapping and product from chapter 5, “Mapping and field types”. Exercise walkthroughs below use the trainer’s separate public dataset.

Chapter map
  • Candidates and preferences
  • Functions and normalization
  • Scripts and a second stage

Add popularity and freshness while preserving textual relevance.

The course targets Elasticsearch 9.4.3. Exercise examples use the public products dataset; other requests illustrate separate teaching indices and may require setup or privileges unavailable in the trainer. Responses are shortened fragments; scores may vary. Check deployment and license requirements for advanced features.

01 / 05

Candidates and preferences

First establish mandatory constraints such as access, stock and category. Rank eligible candidates afterward. A popular product in the wrong category should not appear merely because of a large business signal. Every signal has a range and distribution: sales counts from zero to a million should not be blindly added to text scores.

Check your understanding
02 / 05

Functions and normalization

function_score combines the original score and functions through boost_mode and score_mode. field_value_factor uses numeric fields; logarithmic modifiers compress large ranges but need valid inputs. Decay functions decrease contributions with distance from dates, numbers or locations. rank_feature is designed for prepared positive signals and needs its own mapping.

Check your understanding
03 / 05

Scripts and a second stage

script_score is flexible but expensive across many candidates; scores must be valid non-negative numbers. Rescore applies expensive ranking to a top window on each shard, so a small window limits possible improvements. Check not only the first product but also rare queries and missing feature values.

Multiplication combines text score and rating; validate rating ranges and missing values.

POST /course-products/_search
{
  "query": {
    "function_score": {
      "query": {
        "match": {
          "name": "headphones"
        }
      },
      "field_value_factor": {
        "field": "rating",
        "modifier": "sqrt",
        "missing": 1
      },
      "boost_mode": "multiply"
    }
  }
}

How to read this result

Multiplication combines text score and rating; validate rating ranges and missing values.

Check your understanding
04 / 05

Catalog reasoning example

With text scores 8 and 6 and sales 10 and 100000, naive multiplication overwhelmingly favors the second product. Logarithmic or saturation transformations compress the range, and bounded influence preserves strong text evidence. Do not tune from two numbers: inspect the sales distribution, missing history, new products and exact-model queries.

Check your understanding

Check your understanding

Answer before expanding each explanation.

1. Where does access control belong?

In mandatory server-side eligibility constraints.

2. Why log-transform sales?

To prevent very large values from dominating other signals.

3. What does boost_mode control?

How function output combines with the original score.

4. Does rescore see every document?

No, only a selected candidate window per shard.

5. How do you validate a new weight?

Compare metrics and regressions on judged queries.

Key takeaways

  • In mandatory server-side eligibility constraints.
  • To prevent very large values from dominating other signals.
  • How function output combines with the original score.
  • No, only a selected candidate window per shard.
  • Compare metrics and regressions on judged queries.

Official reference

Ready to put this into practice?

Confirm reading to save your place. Reading and exercise progress are tracked separately in this browser using your guest cookie.