News for hackers. Stuff that matters.
Re:Reasons to replace advanced search with filters by nelsondev on Sunday August 27, 2023 @03:12PM (#37285692)
Counts per filter can be stored pre-computed, using the same inverted index structure the search uses.

Keyword -> (num_docs, doc1,doc3,doc4,…)

So you can quite quickly look up the number of matches.

Re:Reasons to replace advanced search with filters by simonw on Sunday August 27, 2023 @04:15PM (#37286245)
That only works for the simplest case though - showing a count where the starting point was the entire corpus.

With faceted search you usually need to do things like "the user searched for 'x' and filtered for 'price less than $Y', now show counts for each of the different categories" - where pre-calculated counts won't help you.

Search indexes still help here, because they are really good at fast set intersections - so you take the set of document IDs matching your filters so far, then intersect them against the set of IDs that are listed for each of those categories and count the size of that intersection.