Fix contact name search missing expected profiles in global search
Objective
- Make contact search reliably surface the correct existing profile when schedulers search by full name, so they can find and merge duplicates instead of creating new contacts.
- Fix the underlying name-matching and result-cap behavior in global search and scheduling contact pickers — not per-user permissions.
- Reduce duplicate-contact risk when older profiles lack email or use a different email than the current record.
Background
- Product feedback reported that the same name search (e.g. Jeremy Holden) returned different contact counts for different staff. Code review shows no per-user ACL on contact search within a company — all users query the same company-scoped contact index.
- Reported examples:
- Jeremy Holden — one scheduler saw only the top profile; another saw multiple Jeremy Holden entries when searching
holden. A second duplicate profile (no email) was only found via a known address. - Danielle Jones — full-name search returned many other Danielles but not the target contact; searching
dani.j@kw.comfound her immediately. - Follow-up testing: last-name-only search can surface some records; full-name search still fails for the expected contact; profiles without email are especially hard to locate.
- Slack thread: Attik Talk message
- Current search behavior (code-confirmed):
- Global search (
GlobalSearch.tsx) and scheduling contact picker (ContactSearch.tsx) both callGET /contact?search=…scoped by_companyIdonly. - Backend
searchContactsOnlyincontact.tsuses MongoDB Atlas$searchonfirstName,lastName,email, andphoneas separate autocomplete fields withminimumShouldMatch: 1. A multi-word query likeDanielle Jonescan match many contacts on first name alone; the exact record may not rank in the top results. - Global search loads 10 contacts per page (
PAGE_SIZE = 10). When Inspections + Quotes + Contacts filters are all enabled (default), contact infinite scroll is disabled — users only see the first page unless they toggle to Contacts only and scroll. - Scheduling
ContactSearchalso merges Spectora agent/buyer results when the user has Spectora integration — this can make scheduling picker results differ from global search, but is not the primary Attik miss.
Product Decisions
Locked
- Problem type — Bug (search quality / ranking), not per-user permission filtering.
- Primary surfaces — Global search bar (
GlobalSearch.tsx) and scheduling contact picker (ContactSearch.tsx); both use the same backend contact search. - Company scope — Contact search remains company-scoped; no change to multi-tenant isolation.
- User impact — Schedulers must be able to find an existing contact by full name without needing email; missing profiles drive duplicate creation.
Open
- Definition of done (acceptance bar) — For repro queries like
Danielle JonesandJeremy Holden, must the target contact appear in the top 10 results in the default global search view (Inspections + Quotes + Contacts all enabled)? Or is it acceptable if users must toggle to Contacts only and/or scroll to load more? - v1 release scope — Is a backend-only ranking/index fix sufficient for v1, or must the frontend 10-result cap / no-scroll-in-mixed-view behavior ship in the same release?
- Full-name matching strategy — Which approach should ship?
- Split query into first/last tokens and require both on the same record
- Boost exact full-name matches while still allowing partial first-name matches
- Add or use a compound
firstName + lastNameAtlas index path - Product must also confirm expected behavior for partial queries (e.g.
Danielleonly should still return many Danielles, butDanielle Jonesmust rank the exact record highly).
- Result limits and pagination — If frontend is in v1 scope: raise default contact page size, enable infinite scroll in the mixed Inspections+Quotes+Contacts view, and/or show a “more contacts” affordance when results are truncated?
- Contacts list page (
/contacts) — Global search and scheduling picker are in scope; should Tools → Contacts table search (ContactsTableControls→ sameGET /contact?search=…API) be explicitly included in v1 QA/acceptance, or inherit the backend fix only? - Scheduling Spectora merge — In scope for this issue, or a separate follow-up? If in scope: should Spectora-sourced results be deduped against Attik contacts, visually distinguished, or left as-is once Attik ranking is fixed?
- QA fixture contacts — Can product provide Attik contact IDs (or company + enough detail to locate) for the Jeremy Holden duplicate and Danielle Jones repro records so QA has fixed before/after test cases?
- Related work coordination — Should ranking changes here be coordinated with ATT-1192 (phone normalization search) if both touch
searchContactsOnly/ thecontact-searchAtlas index in the same release?
Scope
Backend (attik-backend)
- Contact search —
src/routes/contact.ts→searchContactsOnly: Atlas$searchcompound query oncontact-searchindex (firstName,lastName,email,phoneautocomplete paths). Improve multi-token name matching and ranking so full-name queries surface the intended contact. - Route entry —
GET /contactwithsearch,limit,offsetparams; company filter via_companyId/res.locals.company.
Frontend (attik-frontend)
- Global search —
src/components/navbar/GlobalSearch.tsx: contact fetch viauseServerInfiniteSearchwithPAGE_SIZE = 10;allowInfiniteScrollonly when exactly one entity filter is active;isLikelyAddressgate skips contact search for address-like queries. - Scheduling contact picker —
src/components/scheduling/ContactSearch.tsx: samecontactAPI withlimit: 10; optional Spectora agent/buyer merge whenuser.integrationsincludesspectora. - Contacts list —
src/app/tools/contacts/ContactsTableControls.tsxuses the same search API via URL params; confirm v1 inclusion per product decision above. - Infinite search hook —
src/util/hooks/useServerInfiniteSearch.ts: offset/limit pagination accumulation.
Out of scope (unless product expands)
- Per-user contact visibility / role-based search filtering (not implemented today).
- Contact merge tooling itself (separate workflow once the profile is found).
- Proactive duplicate discovery (ATT-1194) — complementary, not a substitute for fixing search.
References
- Slack repro: Attik Talk thread
- Related: ATT-1192 (phone search normalization), ATT-1194 (duplicate discovery), ATT-1934 (contacts list sort — complementary workaround)
- Key files:
attik-backend/src/routes/contact.ts,attik-frontend/src/components/navbar/GlobalSearch.tsx,attik-frontend/src/components/scheduling/ContactSearch.tsx,attik-frontend/src/app/tools/contacts/ContactsTableControls.tsx
Status: Planned
Log in to comment and vote
No comments yet
Be the first to share your thoughts.