~learn.
0:00 / 1:13
W07 · Search system

Your search works. It's slower and ranks worse. Three filters in must.

transcript

Your search returns the right products. No errors. It's still slower, and ranks worse. Because of where you put three filters.

A million products. The user types running shoes. Then picks footwear, Nike, and under 100 dollars. A teammate puts all four in must.

Query context asks: how well does this document match? It computes a score. Filter context asks: does it match? Yes or no. No score. And it's cacheable.

With selections in must, Elasticsearch scores the brand and price matches. They sway relevance without adding any. And none of it is cached. Move them to filter. Only the text drives scoring. About 3 times faster.

Why so cheap? The first time, it finds 100,000 matches and stores a bitset. 50 milliseconds. Next time, load and intersect. About 1 millisecond. Even for different search text.

What the user typed goes in the query. What they selected goes in the filter. Filters only shrink the set. The score comes only from the text.

Full breakdown in the lecture.