fix(dashboard): make Top Senders use highest-count facet values - #429
Open
CafeLungo wants to merge 1 commit into
Open
fix(dashboard): make Top Senders use highest-count facet values#429CafeLungo wants to merge 1 commit into
CafeLungo wants to merge 1 commit into
Conversation
getTopSenders read Meilisearch's `from` facetDistribution, but the index had no faceting config so defaults applied: maxValuesPerFacet=100 and sortFacetValuesBy=alpha. Meilisearch returned only the alphabetically-first 100 of thousands of distinct senders, and getTopSenders sorted that arbitrary slice by count — surfacing the top of an alphabetical subset rather than the real top senders (max count ~25 across a 200k-email index). Configure faceting to sort facet values by count (and raise maxValuesPerFacet) so facetDistribution returns the highest-frequency values. Also fixes getFacetValues typeahead suggestions. Settings-only change, applied at startup via configureEmailIndex — no reindex required. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The "Top 10 Senders" widget on the dashboard showed wildly inaccurate counts. On a
~200k-email archive the top bar maxed out around 25 — effectively a random/low set
of senders rather than the real leaders.
Root cause
SearchService.getTopSenders()reads Meilisearch'sfromfacet distribution(
index.search('', { facets: ['from'] })). ButconfigureEmailIndex()never set anyfacetingconfig, so Meilisearch applied its defaults:maxValuesPerFacet: 100— only 100 of the many thousands of distinct senders are returnedsortFacetValuesBy: 'alpha'— those 100 are the alphabetically-first addresses, not the most frequentgetTopSenders()then sorted that arbitrary alphabetical slice by count and took thetop 10 — so it surfaced the top of an alphabetical subset, never the true high-volume
senders. The same defect affected
getFacetValues()(facet typeahead suggestions).Fix
Configure faceting on the emails index to sort facet values by count and raise the cap:
Meilisearch now returns the highest-frequency facet values, so the widget sees the
real leaders. Settings-only change, applied at startup via
configureEmailIndex()—no reindex required.
Verification
Rebuilt and ran the stack against a 201,598-email index. Meilisearch's facet
distribution now matches the Postgres ground truth almost exactly:
(Sub-handful differences are docs still in-flight through indexing, or negligible at least.)