Skip to content

fix(dashboard): make Top Senders use highest-count facet values - #429

Open
CafeLungo wants to merge 1 commit into
LogicLabs-OU:mainfrom
CafeLungo:fix/top-senders-facet-sort
Open

fix(dashboard): make Top Senders use highest-count facet values#429
CafeLungo wants to merge 1 commit into
LogicLabs-OU:mainfrom
CafeLungo:fix/top-senders-facet-sort

Conversation

@CafeLungo

Copy link
Copy Markdown

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's from facet distribution
(index.search('', { facets: ['from'] })). But configureEmailIndex() never set any
faceting config, so Meilisearch applied its defaults:

  • maxValuesPerFacet: 100 — only 100 of the many thousands of distinct senders are returned
  • sortFacetValuesBy: 'alpha' — those 100 are the alphabetically-first addresses, not the most frequent

getTopSenders() then sorted that arbitrary alphabetical slice by count and took the
top 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:

faceting: {
    maxValuesPerFacet: 1000,
    sortFacetValuesBy: { '*': 'count' },
},

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:

Sender Widget (Meilisearch) Postgres (truth)
store-news@amazon.com 8,338 8,340
notification@***.com 7,178 7,179
***@gmail.com 5,231 5,252
noreply@***.com 4,979 4,979
enews@***.com 4,245 4,245

(Sub-handful differences are docs still in-flight through indexing, or negligible at least.)

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant