Repository navigation
Description
As a user, I find the difference between
SearchSourceForManyandSearchSourceForSinglequite confusing. Take a look at this for example -PS C:\WINDOWS\system32> winget search resourcehacker Name Id Version --------------------------------------------------- Resource Hacker AngusJohnson.ResourceHacker 5.1.8 PS C:\WINDOWS\system32> winget show resourcehacker No package found matching input criteria.Search clearly returned a single result, so why wouldn't show also find that single result? Is this actually a bug in
SearchSourceForSingle?_Originally posted by Kaleb Luedtke (@Trenly) in #2847 (comment)
SearchForMany searches more fields with
substringsearch, SearchForSingle on the other hand, searches only PackageName, Id, Moniker, PackageFamilyName and ProductCode withCaseInsensitivesearch, which is more strict and less likely to return multiple results.
Originally posted by yao-msft in #2847 (comment)
Feature Request
There are times when SearchForMany will return a single package. When it does, it can make moving from a command like winget search resourcehacker (which returns a single result and uses SearchForMany) to a command like winget install resourcehacker (which returns no results and uses SearchForSingle) very frustrating for users.
Implemetation
My first thought is to start with a search for many. If search for many returns only one result, use that result. If search for many returns multiple results, then fallback to search for single. One downside to this is that if there is only 1 package returned from search for many, it has a higher likelihood of not being the package the user intended due to the additional fields being considered in search.
Second thought is to add a setting for a default query. Neutral/Unset would be the current behavior - some commands use search for single, others use search for many; Strict could be always using search for single; Broad could be always using search for many
Third thought would be to instead have an argument that could be added to make the search for single a bit less restrictive, perhaps using a substring search instead of a case insensitive search while still ignoring the additional fields considered by a search for many
Activity
yao-msft commentedon Jan 13, 2023
Yes. This is one of the main reasons we are strict for SearchForSingle. SearchForSingle means "we are quite certain this is the package" because installation will follow and it is an operation that is considered to change machine state.
We actually made this decision after many complaints about unintentional installation when winget first preview released. We don't want user to search for "foo" then somehow "foobar" gets installed even if "foobar" may be the only package returned in the repo. The actual package "foo" may not be added to the repo yet. Substring search is low confidence for finding a package intended. I would argue against using any substring search for SearchForSingle, and against trying SearchForMany for winget install.
On the other hand, using CaseInsensitive search has its advantages too. It will easily differentiate Microsoft.Team vs. Microsoft.Teams.Preview. This is also a decision made during first preview release after we received many complaints about "too many packages" in winget install without using --exact.
Trenly commentedon Jan 13, 2023
I can appreciate those sentiments. It certainly is a fine balance. I agree that "foobar" wouldn't want to be installed if it was the only one unless that was truly the user intent. On the other hand, there are many times where it is user intent to install foo bar, which can also be frustrating.
I also agree that using the broad search for something like
teamswould return too many results and be confusing. But, looking at the actual search results returned, a majority of them are because of the tags. But, your example teams is also a great example of how search for single can also be a little too enthusiastic (for some people). There are certainly some users who would like to see that there are various versions ofTeamsin the repo.I suppose the request here is for more configurability, and to have a "middle ground" that isn't as strict as the current search for single but also isn't as broad as the search for many
florelis commentedon Jan 13, 2023
Going in a completely different direction.. What if instead of modifying the search behavior to match expectations, we add some messaging to set the expectations?
For example, add a loose match arg to install, and if we find no results show a message like "this arg may find more results, but it is more likely to provide false matches." And then in search if we find a single result, add a message like "this is a loose match search, the same query may produce no search results on commands that require more exact matching."
Trenly commentedon Jan 13, 2023
I think that's what I was trying to get at, just didn't know how to phrase it
denelon commentedon Jan 13, 2023
I've been thinking a bit more broadly about WinGet having a pair of UX (User Experience) modes.
The current mode would be the default behavior. More precise / strict requirements for users.
The new mode would be more "interactive" (not to be confused with interactive install). It would have more prompts and could reduce the typing. It's similar to what we've been working on with:
aetonsi commentedon Mar 22, 2023
Hi i'm coming from the mentioned topic.
I second the idea of a "loose search" argument, but it would also be cool if it could actually be used, eg. to uninstall multiple packages (maybe with a wildcard?):
(here for example i'm trying to obliterate all traces of python from my system)
Would it be possible to add a switch to show the actual filters used internally by the search routine? Like PSWindowsUpdate's
-ShowPreSearchCriteria:Also, a clarification about the order of filters (eg.
--idcoming first,--versionlater) would be helpful. For example the aforementionedPSWindowsUpdatepackage makes the distinction between what it callsPreandPostsearch criteria very clear:In any case, more messaging would be useful
thanks
scscgit commentedon Oct 11, 2026
Has there been any initiative to reconsider the UX of the default behavior? Right now, web sites like winget.run typically add the
-eto the example command, and so as new users, we're annoyingly forced to go study the documentation and find what the-emeans (so we don't run arbitrary commands on our computers); and even then, neither--helpnorhttps://aka.ms/winget-command-helpprovides any information - it doesn't even say that it's a short form of--exact. This GitHub issue ticket was literally the first place where where I found any mention of it.Even if this were documented, having to teach all new users to remember to use a specific parameter at all times is absolutely counter-intuitive and dangerous. When we want to install some app by
id, it typically implies "use that id" and not "please run an arbitrary random algorithm and choose something similar"?