Exercise 2: must vs. filter, "Contributes to Relevance Scoring," and the Missing SQL Equivalent — Possible Solution ==================================================================== THE DIFFERENCE BETWEEN must AND filter ------------------------------ Per this chapter, "must clauses contribute to relevance scoring (search1-6's own material); filter clauses express yes/no criteria that don't affect scoring at all — and, as a result, are more cacheable and efficient." WHAT "CONTRIBUTES TO RELEVANCE SCORING" ACTUALLY MEANS ------------------------------ A must clause doesn't just decide whether a document is included in the results at all — it also feeds into a numeric SCORE that determines how each matching document is RANKED relative to the others (the actual mechanism is covered fully in search1-6's own TF-IDF/BM25 material). A document that matches a must clause more strongly (a better full-text match, per search1-4's own term-frequency material) gets a HIGHER score and ranks higher in the results than a document that matches only weakly. A filter clause, by contrast, answers only a binary yes/no question — does this document satisfy the condition or not — with no notion of "how well" it satisfies it, and has zero influence on where a matching document ranks among the other results; it only decides inclusion or exclusion. WHY SQL'S OWN WHERE CLAUSE HAS NO DIRECT EQUIVALENT ------------------------------ Per this chapter, "ordinary SQL's own WHERE clause has no built-in concept of 'this condition should also feed a relevance score' at all." SQL's WHERE clause is purely a filtering mechanism — every condition in a WHERE clause either includes or excludes a row, with no native concept of one condition contributing MORE to some kind of match quality than another condition does. SQL has no built-in notion of ranking rows by how WELL they satisfy a condition, only whether they satisfy it at all (ORDER BY can sort by an explicit column value afterward, but that's a separate, later step operating on already- filtered rows, not a scoring mechanism baked into the filtering condition itself). This is exactly why the must-vs-filter distinction is genuinely new territory rather than simply "Elasticsearch's version of AND" — SQL was never built with the concept of a condition that BOTH filters AND contributes to a relevance ranking simultaneously, because relevance ranking isn't something SQL's own WHERE clause was ever designed to express at all. WHY THIS WORKS AS AN ANSWER ------------------------------ It explains precisely what "contributes to scoring" means in terms of ranking (not just inclusion/exclusion), and explains specifically why SQL's WHERE clause structurally has no equivalent concept, rather than treating the missing equivalence as an unexplained fact.