Machine Learning: Full-Text Search in JavaScript – Relevance Scoring (2015)

Machine Learning: Full-Text Search in JavaScript – Relevance Scoring (2015)

The algorithm we’ll use is called Okapi BM25, but it builds on two basic concepts: term frequency (“TF”) and inverse document frequency (“IDF”). Term Frequency, abbreviated “TF”, is a simple metric: it’s the number of times a certain word appears in a document. For each term in a search query, calculate its TF-IDF score, add them all up, and whichever document has the highest score is your winner.

Source: burakkanber.com