Skip to content

feat(filter): match multi-word queries as an AND of terms - #1768

Merged
l0gicgate merged 3 commits into
lgse:mainfrom
rwinkelman:feat/1693-multi-word-search
Oct 20, 2026
Merged

l0gicgate merged 3 commits into
lgse:mainfrom
rwinkelman:feat/1693-multi-word-search

Conversation

@rwinkelman

Copy link
Copy Markdown

Description

Filename filter and search now treat space-separated queries as an AND of words after checking for an exact phrase. Typing duck txt still prefers names that contain that phrase, and also finds names like ducks_in_the_pool.txt that contain every word.

Wildcard (*) patterns are unchanged.

Visual evidence

N/A. Matching behavior is covered by unit tests; the listing UI is unchanged.

How to test

  1. Open a folder with files such as ducks_in_the_pool.txt and duck report.txt.
  2. Press Ctrl+F and type duck txt.

Expected result: both files appear; names that contain the contiguous phrase rank ahead of scattered multi-word hits.

Related issue

Closes #1693

Exact phrase hits still rank first. Space-separated words also match
filenames that contain every word, so "duck txt" finds ducks_in_the_pool.txt.
Multi-word queries apply typo tolerance per word, so the filter change
classifier must look at each word rather than the whole query; otherwise
GTK keeps rows hidden that a typo-eligible word now matches. Also match a
single word with trailing whitespace, drop the scoring offset that could
not change ordering within a query, and document the behavior.
@l0gicgate

Copy link
Copy Markdown
Contributor

Review pass: merged main (679d0fd) and pushed a follow-up fix on top of the PR.

Fixed

  • filter_change_for only checked typo eligibility on the whole query, so a multi-word query such as abc tex → abc text was classified MoreStrict. GTK then only re-evaluated visible rows and abc_tent.doc, which now matches through the per-word typo rule, stayed hidden until an unrelated filter change. The classifier now checks each word (src/ui/browser/collection.rs), with a table test in src/ui/browser/collection/tests.rs.
  • The existing GTK test listing_filters_use_and_highlight_fuzzy_terms_only_in_tenxer_mode asserted that rep md does not match gamma-report.md outside Tenxer mode. That assertion no longer holds by design; it now checks a Tenxer-only form (^gamma .md$) instead.

Simplified

  • filter_name_matches now folds the word loop into one expression, and a single word followed by whitespace (duck ) keeps matching duck.txt instead of emptying the listing until the next character is typed.
  • Dropped the -500 score offset in filter_score_normalized: every non-phrase hit of a multi-word query received the same offset, so it could not change ordering within a query. Phrase hits already rank first through the fuzzy score, which is now covered by multi_word_filters_rank_phrase_hits_above_scattered_words in src/services/search/tests/scope.rs.
  • Documented multi-word matching in docs/keyboard-navigation.md.

Verification

  • cargo fmt --all --check, cargo clippy --all-targets --all-features -- -D warnings, and the full headless Rust suite (3418 passed, 0 failed, 11 ignored).
  • Manual check under a private Xvfb: duck txt lists duck report.txt ahead of ducks_in_the_pool.txt; duck keeps all three duck files visible.

@l0gicgate
l0gicgate merged commit fd63272 into lgse:main Oct 20, 2026
9 checks passed
IKurokami pushed a commit to IKurokami/strata that referenced this pull request Oct 23, 2026
* feat(filter): match multi-word queries as an AND of terms

Exact phrase hits still rank first. Space-separated words also match
filenames that contain every word, so "duck txt" finds ducks_in_the_pool.txt.

* fix(filter): classify typo eligibility per word for multi-word queries

Multi-word queries apply typo tolerance per word, so the filter change
classifier must look at each word rather than the whole query; otherwise
GTK keeps rows hidden that a typo-eligible word now matches. Also match a
single word with trailing whitespace, drop the scoring offset that could
not change ordering within a query, and document the behavior.

---------

Co-authored-by: Ray Winkelman <[email protected]>
Co-authored-by: Pierre Berube <[email protected]>
(cherry picked from commit fd63272)
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.

Search by multiple words

2 participants