Skip to content

feat(search): match multi-word queries as an AND of terms in global search - #1899

Merged
l0gicgate merged 4 commits into
mainfrom
feat/1889-global-search-multi-word
Oct 27, 2026
Merged

l0gicgate merged 4 commits into
mainfrom
feat/1889-global-search-multi-word

Conversation

@JoeJoeflyn

@JoeJoeflyn JoeJoeflyn commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Global search (Ctrl+K) now matches space-separated terms across filenames and paths, so duck txt finds ducks_in_the_pool.txt and subfolder txt finds nested/subfolder/notes.txt. It reuses the folder filter's allocation-free substring and typo matcher from #1768. Typo checks compare character-aligned UTF-8 suffixes directly instead of repeatedly decoding them.

Match tiers keep contiguous filename hits ahead of contiguous path hits, then all-in-filename term matches, path-only term matches, and the existing fuzzy fallback. Path length, depth, and fuzzy bonuses cannot reverse those tiers. Fuzzy fallback is preserved, so multi-word queries are not a strict filter.

Visual evidence

N/A. Matching and ranking change only; the search palette layout is unchanged.

How to test

  1. Under Home, create duck txt notes.md, ducks_in_the_pool.txt, duck.md, and nested/subfolder/notes.txt.
  2. Open global search with Ctrl+K and type duck txt.
  3. Replace the query with subfolder txt. Repeat with matching files under long or deeply nested paths.

Expected result:
duck txt finds the phrase match before the scattered filename match. subfolder txt finds notes.txt. Stronger match tiers remain first regardless of path length or depth; any fuzzy-only results rank below term matches.

Related issue

Closes #1889

…earch

Match space-separated queries in global search as an AND of terms after checking
for an exact contiguous phrase, allowing users to filter global search results
by adding keywords or file extensions.

Reuse text_matches_words across filter_name_matches and fuzzy_score_normalized
with zero heap allocation per candidate item.
@JoeJoeflyn

Copy link
Copy Markdown
Collaborator Author

Review fixes

Pushed c5aade5f (fix(search): preserve match tiers across path penalties).

  • Separate match tiers from bounded within-tier scores so path length, depth, and fuzzy bonuses cannot invert the ordering promised by Search by multiple words in global search #1889 and this PR.
  • Add one table-driven regression covering every adjacent tier boundary, including both reproduced long-path/depth-63 failures. Existing filename, Unicode, scope, incremental, and parallel-scoring coverage is retained; no tests removed.
  • Extend global-search-finds-file-under-home to refine quarterly to quarterly txt, retaining the .txt hit and removing the .md hit. Both keyboard-layout routes remain covered.
  • Correct the PR body's shortcut to Ctrl+K and explicitly document the preserved fuzzy fallback rather than implying strict AND filtering.

main at be3343a5 was already contained; no merge was needed.

Validation

Scope: global-search scoring and its shared literal-name filter caller. The separate path/folder matcher, indexing/lifecycle implementation, preferences, dependencies, and build infrastructure are unchanged, so validation remained targeted rather than running full local suites.

  • ./scripts/test-headless.py services::search:: — 86 passed.
  • ./scripts/test-headless.py ui::search:: — 8 passed, including startup/live saved search preferences and keyboard/result-update callers.
  • ./scripts/test-headless.py listing_filters_use_and_highlight_fuzzy_terms_only_in_tenxer_mode — 1 passed.
  • ./scripts/test-headless.py multi_word_match_tiers_survive_long_paths_depth_and_fuzzy_bonuses — 1 passed again after formatting-only fixes; earlier results retained.
  • ./scripts/qa.sh global-search-finds-file-under-home global-search-arrows-keep-typing wildcard-filter-patterns — 4 passed on the final code in the pinned container.
  • ./scripts/qa.sh global-search-finds-file-under-home — both variants also passed in repeated scoped runs. An intentionally incorrect expected result failed at the new refinement assertion; it was restored and both variants rerun successfully.
  • ./scripts/quality.sh fmt, ./scripts/quality.sh clippy — passed after correcting formatting.
  • git diff --check — clean.

A private qa-drive.sh session also showed the long-path phrase before scattered words and the depth-63 filename before path-only matches, with no GTK warnings. This was a hands-on check, not counted as test evidence. QA quality remains manually assessed at 2/3/3/3 (20); independent Haiku grading was unavailable because the local CLI failed to start.

All required CI checks are green for c5aade5f as of 2026-10-26 13:11 UTC. CI's manual-only QA job was skipped; the targeted GUI runs above passed locally. Full local Rust and QA suites were intentionally not run for this bounded change.

Compare character-aligned UTF-8 suffixes directly instead of walking cloned character iterators for each possible edit. Preserve Unicode insertion, deletion, substitution, and transposition behavior without adding allocations or query-cache complexity.
@JoeJoeflyn

Copy link
Copy Markdown
Collaborator Author

Performance follow-up

Pushed 926527f4 (perf(search): compare typo suffixes without decoding). The private typo matcher now compares character-aligned UTF-8 suffix slices instead of repeatedly walking cloned character iterators after the first difference. No allocation, query-cache layer, or matching/ranking behavior was added. The existing whole-filename-word test owns six additional Unicode substitution/insertion/deletion/transposition cases.

Measurements

Compared with c5aade5f using production matcher/scorer snapshots, 200,000 pre-folded candidates from the existing ranked-fixture families, pinned Rust 1.98.1 container, optimized compilation, one pinned CPU, nine interleaved samples and three batches per sample. These measure scoring CPU work, not indexing, result publication, or UI latency.

Filename-term matching used 8.5–14.7% less CPU across eight queries. Examples, milliseconds per 200,000 candidates:

Query Before After
needle 31.429 26.808
needle txt 45.361 40.744
archive needle 41.275 37.228
missing words 40.036 35.671
neelde txt 46.232 40.008
objects rs 34.703 31.110
配置 txt 16.440 14.747
needle txt pdf 42.937 39.279

Whole global-query scoring was workload-sensitive: some improved, others were effectively unchanged; no general UI-latency improvement is claimed. All benchmark hit counts and score checksums matched, as did 1,863,225 generated ASCII/Unicode word pairs. A single-pass filename/path prototype had inconsistent benefits and was discarded.

Scratch command: bash target/pr-1899-performance/benchmark.sh. The harness and raw results remain ignored under target/pr-1899-performance/, not committed.

Published performance commit validation

  • ./scripts/test-headless.py services::search:: — 86 passed.
  • ./scripts/test-headless.py listing_filters_use_and_highlight_fuzzy_terms_only_in_tenxer_mode — 1 passed.
  • ./scripts/qa.sh global-search-finds-file-under-home global-search-arrows-keep-typing wildcard-filter-patterns — 4 passed.
  • ./scripts/quality.sh fmt, ./scripts/quality.sh clippy, git diff --check — passed.

The bounded selection covers global/recursive scoring, shared default listing filters, Unicode/typo rules, ranking, and incremental/parallel scoring. No GUI behavior changed, so no scenarios were rewritten for the optimization.

CI blocker and unpushed dependency proposal

At 926527f4, all build/lint/Rust-shard/metadata checks pass. Dependency and spelling policy fails on four newly reported advisories in the unchanged zstd chain: RUSTSEC-2026-0391, -0398, -0403, and -0410. Spelling itself passes. CI's manual-only QA job is skipped.

A minimal compatible update was prepared with cargo update -p zstd --precise 0.14.3: zstd 0.14.3, zstd-safe 8.2.0, and zstd-sys 2.1.2+zstd.1.5.7. No advisory exceptions were added. Dependency impact justified escalating to both full pinned suites:

  • ./scripts/quality.sh test — the original run completed with 3,561 passed, 5 failed, 11 ignored in the main target. The command wrapper timed out, but I reattached to the same running container; the suite was not restarted. Four failed cases pass on subsequent exact isolated reruns. ui::progress_dock::tests::already_hovered_notifications_start_paused_and_pinning_is_independent still fails and also fails with the original dependencies.
  • ./scripts/qa.sh --test-threads 4 — 607 passed, 1 failed. ./scripts/qa.sh media-details-properties-only/icons reproduces that failure: its Properties click targets y=973 below the 900px private display. This scenario is outside search/dependency code; fix(preview): preserve words, RTF emoji and raw H.264 playback #1901 already contains work on its long-menu input route.
  • Exact Rust reproductions used bash target/pr-1899-performance/reproduce-rust.sh with the same pinned image, private Xvfb/private D-Bus, and the five exact failing test names. Full suites were not rerun to obtain a green summary.

The dependency proposal was not committed or pushed because those unrelated validation blockers remain. It is preserved at target/pr-1899-performance/zstd-update.patch; the checkout has been restored to published 926527f4 and is clean. Resolving the unrelated blockers or accepting their known failures needs an owner decision before including that broader change.

@JoeJoeflyn

Copy link
Copy Markdown
Collaborator Author

Per the owner’s request, the zstd dependency advisories are left for a separate fix. No dependency updates or associated baseline-test cleanup were committed or pushed; the interrupted diagnostic run was stopped, and the checkout is clean at 926527f4.

All other required CI checks pass. The remaining Dependency and spelling policy failure is the existing RustSec audit blocker documented above; it is not being reported as passed. The manual-only CI QA job remains skipped.

@l0gicgate

l0gicgate commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Review and cleanup

main (be3343a5) was already contained, so no merge was needed.

Review against the description and #1889. All claims confirmed:

  • Space-separated terms match across the filename (tier 3) and the path (tier 2) after the contiguous filename and path hits (tiers 5 and 4). The fuzzy fallback stays in tier 1, so this isn't a strict AND filter. src/services/search.rs fuzzy_score_normalized.
  • Tier separation: (tier << 32) + clamp(score, i32) stops length, depth and fuzzy bonuses from crossing tiers. It also fixes a pre-existing case in filter_score_normalized, where very deep contiguous hits could fall below its non-contiguous filter scores.
  • The within_one_edit suffix comparison is equivalent to the previous iterator version for substitution, insertion, deletion and transposition. The new Unicode rows in pattern/tests.rs cover each edit kind.
  • Search by multiple words #1693's behaviour from the folder filter now applies to global search, as Search by multiple words in global search #1889 asks: duck txt → ducks_in_the_pool.txt, and an extension term narrows the results (QA global-search-finds-file-under-home).

Tests audited: multi_word_match_tiers_survive_long_paths_depth_and_fuzzy_bonuses, global_search_matches_multi_word_queries_and_ranks_phrase_above_scattered_words, the new typo rows, the two parallel-scoring rows and the QA refinement step all guard distinct behaviour. None were removed. The scope test's fixtures can't reach the fuzzy fallback through the random tempdir name, so it isn't flaky. Both added comments explain intent that isn't otherwise obvious and were kept.

Fixes pushed

  • 4d64e0e7 refactor(search): keep the single-term matcher private to pattern. text_matches_word was pub(crate) but only used inside pattern.rs.

Validation

  • ./scripts/test-headless.py services::search::: 86 passed
  • cargo fmt --all --check, cargo clippy --all-targets --all-features -- -D warnings (native), git diff --check: clean
  • Not rerun: qa.sh. This review changed only the visibility of one helper, and the author's container runs of the affected scenarios still apply.

CI at 4d64e0e7: every check is green except Dependency and spelling policy. That check fails on the pre-existing zstd-chain advisories (RUSTSEC-2026-0391, -0398, -0403, -0410), which are unrelated to this diff and left for a separate fix as agreed above. The manual-only QA job was skipped.

@l0gicgate
l0gicgate merged commit 128dcfc into main Oct 27, 2026
10 of 11 checks passed
@l0gicgate
l0gicgate deleted the feat/1889-global-search-multi-word branch October 27, 2026 04:17
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.

Search by multiple words in global search

2 participants