src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/README.md
The module does not always forward the user query to Windows Search unchanged.
For simple free-text queries, it broadens filename matching so search feels more natural. For queries that already look like AQS or other Windows Search syntax, it does not rewrite them.
That split is intentional. The module is trying to improve plain filename search without breaking structured Windows Search queries.
If the input looks structured, we pass it through ISearchQueryHelper.GenerateSQLFromUserQuery(...) as-is.
Examples:
name:reportkind:folderkind:folder AND report*report*C:\Userssize>10MB(report)Parentheses are treated conservatively because they can be real query syntax.
For simple free-text input we may build two filename restrictions:
LIKE restriction on System.FileNameCONTAINS(System.ItemNameDisplay, ...) restrictionThey serve different purposes:
LIKE preserves the original text literallyCONTAINS gives better indexed matching and can normalize separator-like punctuationThe primary query may use both.
The fallback query uses the LIKE branch only.
The broadening is intentionally asymmetric.
Desired behavior:
red should find [red][red] should stay mostly literalIn other words:
This is the most important design rule in the module.
Some punctuation behaves like a separator inside filenames.
Examples:
foo-bar20220409-tontrager.xlsxUsers usually expect broadening here, because tontrager should still find 20220409-tontrager.xlsx.
Other punctuation usually signals literal intent.
Examples:
[red]{draft}<todo>Those should usually stay on the literal filename path instead of being normalized to bare words.
| User input | Behavior |
|---|---|
red | broad plain-text search; can match random [red] search.txt |
[red] | literal filename match; does not also broaden to plain red |
foo-bar | keeps literal foo-bar matching and also broadens as a separator-style term |
term Kind:Folder | broadens term, preserves Kind:Folder |
% | treated as a literal percent sign in the filename match |
_ | treated as a literal underscore in the filename match |
(report) | not rewritten locally; passed through to Windows Search |
Some inputs are valid literal filename searches but poor full-text searches.
Typical failure mode:
CONTAINS(...) side returns QUERY_E_ALLNOISEWhen both branches exist:
CONTAINS(...) OR LIKE ...LIKE ... onlyThe fallback exists so punctuation-heavy or noisy input can still produce useful filename matches.