Skip to content

fix(api): skip fuzzy matching for one- and two-character player searches - #1010

Open
ugcodrr wants to merge 4 commits into
mainfrom
fix/autocomplete-short-queries
Open

ugcodrr wants to merge 4 commits into
mainfrom
fix/autocomplete-short-queries

Conversation

@ugcodrr

@ugcodrr ugcodrr commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Description: Player search's fuzzy Redis lookup walks most of the ~2M-name dictionary for one- and two-character queries, so those now do a plain prefix lookup instead.

Merge order for the perf PRs is in #1002.

Testing: with redis-cli monitor | grep FT.SUGGET running, /player/search?query=ab sends no FUZZY and /player/search?query=abc does.

@vercel

vercel Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
statsify Ignored Ignored Nov 1, 2026 11:28pm UTC

A fuzzy FT.SUGGET on one or two characters walks most of the autocomplete
dictionary. Keep those results in memory for 60 seconds; longer queries still
go to Redis every time, and failed searches aren't kept. Queries made of
username characters share an entry across case, since FT.SUGGET ignores case.
@ugcodrr
ugcodrr force-pushed the fix/autocomplete-short-queries branch from f65b78f to bb7f7ad Compare October 29, 2026 20:50

@momenazhar momenazhar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comments

@Injectable()
export class PlayerSearchService {
private logger = new Logger("PlayerSearchService");
private readonly shortQueries = new Map<string, { expiresAt: number; players: Promise<string[]> }>();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not a big fan of adding a cache like this because its now making the api somewhat stateful.

@ugcodrr ugcodrr changed the title fix(api): cache one- and two-character player searches for a minute fix(api): skip fuzzy matching for one- and two-character player searches Nov 1, 2026
@vercel

vercel Bot commented Nov 3, 2026

Copy link
Copy Markdown

Deployment failed for project statsify with the following error:

Resource is limited - try again in 1 day (more than 100, code: "api-deployments-free-per-day").

Learn More: https://vercel.com/statsify-net?upgradeToPro=build-rate-limit

ugcodrr added a commit that referenced this pull request Nov 5, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants