Skip to content

fix: relax search token matching to require at least one match#27

Merged
steipete merged 4 commits intoopenclaw:mainfrom
afmire877:fix/search-token-matching
Jan 24, 2026
Merged

fix: relax search token matching to require at least one match#27
steipete merged 4 commits intoopenclaw:mainfrom
afmire877:fix/search-token-matching

Conversation

@afmire877
Copy link
Contributor

@afmire877 afmire877 commented Jan 24, 2026

Summary

  • Changed search token matching from requiring ALL query tokens to requiring AT LEAST ONE token
  • This fixes searches returning no results when not all keywords appear in the skill metadata
  • Vector similarity now properly determines relevance instead of being over-filtered

Problem

The search was requiring ALL query tokens to exist in the skill's displayName, slug, or summary. For example, searching "HTTP API client" would fail to match skills about "HTTP API" that didn't explicitly mention "client" - even though the vector search found them as semantically relevant.

Solution

Changed from .every() to .some() in matchesExactTokens() so at least one token must match. This keeps a minimal keyword filter while allowing vector similarity to determine relevance.

Test plan

  • All 283 existing tests pass
  • Updated test reflects new behavior
  • Manual test: search for multi-word queries and verify results appear

🤖 Generated with Claude Code

The search was requiring ALL query tokens to exist in the skill's
displayName, slug, or summary. This was too strict and caused valid
results to be filtered out. For example, searching "HTTP API client"
would fail to match skills about "HTTP API" that didn't mention "client".

Changed from `.every()` to `.some()` so at least one token must match,
allowing the vector similarity to determine relevance for the rest.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@vercel
Copy link
Contributor

vercel bot commented Jan 24, 2026

@ahmed-mire is attempting to deploy a commit to the Amantus Machina Team on Vercel.

A member of the Team first needs to authorize it.

@afmire877
Copy link
Contributor Author

Addressing Search Broken
#15
#17
#26

console.log({ queryTokens, textTokens })
// Require at least one token to prefix-match, allowing vector similarity to determine relevance
return queryTokens.some((queryToken) =>
textTokens.some((textToken) => textToken.includes(queryToken)),
Copy link
Contributor

@vercel vercel bot Jan 24, 2026

Choose a reason for hiding this comment

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

Search matching uses substring matching (includes) instead of prefix matching (startsWith), causing false positive matches

Fix on Vercel

Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
@steipete steipete merged commit a16e624 into openclaw:main Jan 24, 2026
1 of 2 checks passed
@steipete
Copy link
Contributor

Landed via temp rebase onto main.\n\n- Gate: bun run lint && bun run build && bun run test\n- Land commit: a695706\n- Merge commit: a16e624\n\nThanks @afmire877!

aronchick pushed a commit to aronchick/clawhub that referenced this pull request Feb 19, 2026
…law#27)

* fix: relax search token matching to require at least one match

The search was requiring ALL query tokens to exist in the skill's
displayName, slug, or summary. This was too strict and caused valid
results to be filtered out. For example, searching "HTTP API client"
would fail to match skills about "HTTP API" that didn't mention "client".

Changed from `.every()` to `.some()` so at least one token must match,
allowing the vector similarity to determine relevance for the rest.


* fix: update matchesExactTokens to require prefix matching for query tokens

* more inclusive token check

* Update convex/lib/searchText.ts


---------

Co-authored-by: Ahmed <ahmed.mire@kaluza.com>
oolong-tea-2026 added a commit to oolong-tea-2026/clawhub that referenced this pull request Mar 17, 2026
When searching for a skill by its exact slug (e.g. 'ima-all-ai'), the
result could be missing from the first page because:

1. The vector search candidate pool (75-256) might not include the skill
2. matchesExactTokens uses `.some()` (by design, see openclaw#27), so unrelated
   skills with common tokens like 'ai' inflate exactMatches count
3. When exactMatches >= limit, lexicalFallbackSkills is skipped entirely,
   along with its exact slug lookup via the by_slug index

Fix: after all recall stages (vector + exactMatches + lexicalFallback),
check whether the candidate slug (reconstructed from query tokens via
`join('-')`) is present in merged results. If missing, perform a single
O(1) index lookup via the new `lookupExactSlug` internalQuery.

This ensures exact slug matches are never lost regardless of vector
search coverage or the matchesExactTokens filtering threshold.

Co-Authored-By: 戴硕 <daishuo@gmail.com>
oolong-tea-2026 added a commit to oolong-tea-2026/clawhub that referenced this pull request Mar 17, 2026
When searching for a skill by its exact slug (e.g. 'ima-all-ai'), the
result could be missing from the candidate pool because:

1. The vector search candidate pool (75-256) might not include the skill
2. matchesExactTokens uses `.some()` (by design, see openclaw#27), so unrelated
   skills with common tokens like 'ai' inflate exactMatches count
3. When exactMatches >= limit, lexicalFallbackSkills is skipped entirely,
   along with its exact slug lookup via the by_slug index

Fix: after all recall stages (vector + exactMatches + lexicalFallback),
reconstruct the candidate slug from query tokens and check if it exists
in merged results. If missing, perform a single O(1) index lookup via
the new `lookupExactSlug` internalQuery to ensure it enters the
candidate pool. It then participates in normal scoring and ranking —
SLUG_EXACT_BOOST (1.4) makes it very likely to rank first, but the
fix does not force any particular ranking.

Co-Authored-By: 戴硕 <daishuo@gmail.com>
oolong-tea-2026 added a commit to oolong-tea-2026/clawhub that referenced this pull request Mar 17, 2026
When searching for a skill by its exact slug (e.g. 'ima-all-ai'), the
result could be missing from the candidate pool because:

1. The vector search candidate pool (75-256) might not include the skill
2. matchesExactTokens uses `.some()` (by design, see openclaw#27), so unrelated
   skills with common tokens like 'ai' inflate exactMatches count
3. When exactMatches >= limit, lexicalFallbackSkills is skipped entirely,
   along with its exact slug lookup via the by_slug index

Fix: after all recall stages (vector + exactMatches + lexicalFallback),
reconstruct the candidate slug from query tokens and check if it exists
in merged results. If missing, perform a single O(1) index lookup via
the new `lookupExactSlug` internalQuery to ensure it enters the
candidate pool. It then participates in normal scoring and ranking —
SLUG_EXACT_BOOST (1.4) makes it very likely to rank first, but the
fix does not force any particular ranking.

Co-Authored-By: 戴硕 <daishuo@gmail.com>
oolong-tea-2026 added a commit to oolong-tea-2026/clawhub that referenced this pull request Mar 17, 2026
When searching for a skill by its exact slug (e.g. 'ima-all-ai'), the
result could be missing from the candidate pool because:

1. The vector search candidate pool (75-256) might not include the skill
2. matchesExactTokens uses `.some()` (by design, see openclaw#27), so unrelated
   skills with common tokens like 'ai' inflate exactMatches count
3. When exactMatches >= limit, lexicalFallbackSkills is skipped entirely,
   along with its exact slug lookup via the by_slug index

Fix: after all recall stages (vector + exactMatches + lexicalFallback),
reconstruct the candidate slug from query tokens and check if it exists
in merged results. If missing, perform a single O(1) index lookup via
the new `lookupExactSlug` internalQuery to ensure it enters the
candidate pool. It then participates in normal scoring and ranking —
SLUG_EXACT_BOOST (1.4) makes it very likely to rank first, but the
fix does not force any particular ranking.

Co-Authored-By: 戴硕 <daishuo@gmail.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.

3 participants