News for hackers. Stuff that matters.
Re:What Postgres Full Text Search Is Missing by simonw on Tuesday August 06, 2024 @04:11PM (#41174816)
Doesn't that affect BM25 with a solution like Elasticsearch as well? Or is that smart enough to apply filters to the corpus statistics before calculating relevance?

You could solve that in SQLite by giving each user their own separate FTS table - not impossibly complex, but would grow increasingly messy if you have 10s of thousands of users.

Re:What Postgres Full Text Search Is Missing by vosper on Tuesday August 06, 2024 @04:40PM (#41175085)
One way to address this in Elasticsearch would be to put each customers documents in their own index. Other than that, as far as I can tell it's not smart enough to apply filters first.

Also, shards can affect BM25 scoring: https://www.elastic.co/blog/practical-bm25-part-1-how-shards...

Re:What Postgres Full Text Search Is Missing by nemo44x on Tuesday August 06, 2024 @07:05PM (#41176443)
It’s why you need “enough” data. Generally the distribution of teens is a power-law distribution. There’s a set of common terms and a very long tail of other terms. This will be the case across every shard if you do in fact have enough data per shard. This becomes a factor in certain distributed aggregations as well. YMMV of course.

In general you trade accuracy for speed. You tend to get a lot of speed for just a small amount of accuracy sacrifice.

Re:What Postgres Full Text Search Is Missing by sroussey on Wednesday August 07, 2024 @12:52AM (#41178350)
Oh sure, but it is a side channel attack to be aware of.
Re:What Postgres Full Text Search Is Missing by eskibars on Wednesday August 07, 2024 @03:29AM (#41179031)
I wrote this blog :). Good to see it still getting use.

FYI for folks just skimming this, shards can affect scoring, but they don't have to. 2 mitigations: 1. The default in Elasticsearch has been 1 shard per index for a while, and many people (if not most) probably don't need more than 1 shard

2. You can do a dfs_query_then_fetch query, which adds a small amount of latency, but solves this problem

The fundamental tenant is accurate here that any time you want to break up term statistics (e.g. if you want each user to experience different relevance results for their own term stats) then yes, you need a separate index for that. I'd say that's largely not all that common though in practice.

A more common problem that warrants splitting indices is when you have mixed language content: the term "LA" in Spanish content adds very little information while it adds a reasonable amount of information in most English language documents (where is can mean Los Angeles). If you mix both content together, it can pollute term statistics for both. Considering how your segments of users and data will affect scoring is absolutely important as a general rule though, and part of why I'm super excited to be working on neutral retrieval now

Re:What Postgres Full Text Search Is Missing by vibbix on Wednesday August 07, 2024 @08:39AM (#41180772)
Thanks for the clarifications! I've been spending the last 3 weeks deep in the weeds of TF/IDF scoring and was about to give up on Elastic Search when this got posted. The article has been eye opening!!!