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

A store full of running shoes. Search running shoes: no results.

transcript

Your online store sells running shoes. Lots of them. A user searches Running Shoes. No results found. No error either.

Here's what happens to a product name before it's indexed. It's analysed. Character filters clean it. The tokenizer splits it into words. Token filters lowercase each word, drop stop words, and stem it. Red Nike Running Shoes is stored as red, nike, run, shoe.

Now the query. Someone only split it on spaces. The index holds run and shoe. The query asks for Running and Shoes. Capitals. No stemming. No token matches. So no results. And no error to warn you.

The fix: run the same analyzer at index time and at query time. Now the query becomes run and shoe too. Every running shoe matches.

Get it right, and analysis does more. Stemming, so running finds run and runs. Synonyms: Comfortable Leather Couch also gets sofa. So a search for sofa finds it. And character filters turn café into cafe.

The tokens in the index are the only truth search knows. So the same analyzer runs at index time and query time. Or the tokens won't match.

Full breakdown in the lecture.