Repository navigation
feat(platform): match questions, not just typed names, in entity search - #2983
Merged
Merged
Conversation
Entity search has one matching rule: every whitespace token must hit some field. That is right when a person TYPED the term into a picker, and wrong when the term is a question, because most of a question's words are absent from the data by construction. "recruitment ads Facebook ad account project tasks" cannot match a task titled "Set up Facebook ad account" — "recruitment" alone sinks it. Add an opt-in `matchMode: 'any'` to the scan engine for callers whose term is a question. It drops function words across the three locales the app ships, keeps rows that hit a surviving token at word-start or better, and leaves the existing relevance scoring to put the row that answered the most of the question first. A query that is nothing but function words matches NOTHING rather than everything, so a caller can report "too general" instead of returning the whole org. `'all'` stays the default, so every existing caller is untouched. Also add tasks and projects strategies, and collapse the second copy of `contactsSearchStrategy` that had grown in `list_contacts_paginated.ts` onto the shared one. Matching and ranking now read the same `queryTokens`, so a row can never be kept by one rule and ordered by another.
7 tasks
This was referenced Aug 31, 2026
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.
Why
Entity search has exactly one matching rule (
convex/lib/search/relevance.ts): every whitespace-delimited token must hit some configured field. That is the right rule when a person typed the term into a picker or a mention autocomplete. It is the wrong rule when the term is a question, because most of a question's words are absent from the data by construction.Concretely — a real query that came back empty:
cannot match a task titled "Set up Facebook ad account".
recruitmentalone sinks it, and so doprojectandtasks.This is groundwork: it unblocks giving the chat assistant reach into tasks, projects and conversations, where the search term is always a question rather than a typed name.
What changed
An opt-in
matchModeon the scan engine.'all'(the default, unchanged) requires every token.'any':adinsideoverhead) is not enough on its own once tokens are OR-ed;Matching and ranking now read the same
queryTokens, so a row can never be kept by one rule and ordered by another.The stopword list deliberately carries no domain vocabulary —
open,doneandrevieware board statuses, and dropping them would make the most common question about a board unanswerable.Two new strategies,
tasksandprojects, following the shape and doc-comment convention ofstrategies/contacts.ts. Both note the index-name trap:tasks/projectsname their org indexby_organization, notby_organizationId, andscopedSubstringSearch@ts-expect-errors itswithIndexcall — so a wrong name fails at runtime with no type error.One duplicate collapsed.
contacts/list_contacts_paginated.tshad grown its own byte-identical copy ofcontactsSearchStrategywhile importingrunEntitySearchfrom the shared barrel. It now imports the shared one.Verification
bun run checkclean. 424 tests pass acrossconvex/lib/search,convex/contacts,convex/documents; typecheck, oxlint and oxfmt clean; SAST 0 findings.Every new assertion was mutation-tested — seen red before being accepted:
'any'matches with AND instead of ORMIN_ANY_TIERlowered to accept mid-word substringsTwo tests initially passed under the stopword mutation for the wrong reason — their fixtures did not actually contain the function words being filtered. Both were rewritten against fixtures that do, and now fail as intended.
The reported query is pinned as a regression test asserting both halves: it must not match under
'all', and must match under'any'.Note
tasksSearchStrategyandprojectsSearchStrategyhave no runtime caller yet — they are exercised by tests here and consumed by the follow-up that adds the chat legs.