It's important that we pad the term matches to the total tokens searched so that terms that do not exist in our entire index are handled with a TF-IDF of 1. Otherwise, if you'd search for "foobar" and there is not a single document with "foobar" in your index, it would not be considered in the cosine similarity giving you completely wrong results.
It's important that we pad the term matches to the total tokens searched so that terms that do not exist in our entire index are handled with a TF-IDF of 1. Otherwise, if you'd search for "foobar" and there is not a single document with "foobar" in your index, it would not be considered in the cosine similarity giving you completely wrong results.