A classic keyword-matching algorithm. The 'old way' of search that still works great.
BM25 (short for 'Best Match 25') is a math formula for ranking documents by how well they match your keyword query. It's been around since the 1990s. It handles word frequency, document length, and rare-word bonuses in a clever way. Elasticsearch, OpenSearch, and most classic search engines use it as their core scoring function.
The best modern RAG systems don't use semantic search alone. They combine BM25 (for exact-term precision) with semantic search (for meaning) - this is called 'hybrid search.' BM25 catches the things semantic search misses, like proper names, codes, and exact phrases.