Postgres Full Text Search vs. the Rest
One thing that isn't really covered in this article is relevance calculations.<p>A surprising (to me) thing about PostgreSQL FTS is that it doesn't do TF/IDF or BM25 relevance calculations.<p>These calculations take statistics about the entire corpus into account - they do things like ranking a document higher if it contains terms from the search which are statistically rare in the overall corpus.<p>PostgreSQL FTS uses how often the search terms appear in the document as part of the ranking score, but doesn't look at how common/rare individual terms are. <a href="https://www.postgresql.org/docs/current/textsearch-controls.html#TEXTSEARCH-RANKING" rel="nofollow">https://www.postgresql.org/docs/current/textsearch-controls....</a><p>OpenSearch/Elasticsearch uses BM25: <a href="https://opensearch.org/docs/latest/opensearch/rest-api/explain/" rel="nofollow">https://opensearch.org/docs/latest/opensearch/rest-api/expla...</a><p>SQLite stores these kinds of statistics and can support BM25 or TF/IDF or custom ranking functions. I wrote more about that here: <a href="https://simonwillison.net/2019/Jan/7/exploring-search-relevance-algorithms-sqlite/" rel="nofollow">https://simonwillison.net/2019/Jan/7/exploring-search-releva...</a><p>Meilisearch does something a bit different (on reading this I don't think it considers full corpus statistics, but I may be misinterpreting that): <a href="https://docs.meilisearch.com/learn/core_concepts/relevancy.html#ranking-rules" rel="nofollow">https://docs.meilisearch.com/learn/core_concepts/relevancy.h...</a><p>It looks like Typesense only considers the documents, not the overall corpus: <a href="https://typesense.org/docs/guide/ranking-and-relevance.html" rel="nofollow">https://typesense.org/docs/guide/ranking-and-relevance.html</a>