Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"composer search" should return more popular packages first (or better match namespaces in name-only mode) #10325

Closed
dkarlovi opened this issue Dec 1, 2021 · 5 comments · Fixed by #10336
Labels
Milestone

Comments

@dkarlovi
Copy link

dkarlovi commented Dec 1, 2021

Searching for

composer search ^laravel -N

returns all sorts of packages, but laravel/ is the most obvious example what one would like to see here.

If I search

composer search ^laravel/ -N

I get better matching results. These two queries should behave basically in the same way, this type of search is similar to as-you-type auto-suggest you'd get on Google or some e-commerce site.

The reason is in #10320, when you do

composer require larav<TAB>

it will auto-complete to

composer require laravel-

because it's offering more than 150 laravel--prefixed packages in front of laravel/*.

So, either:

  • sort by package downloads by default (?)
  • more tightly match namespaces (namely, laravel/ is a better match to the query laravel than laravel-foo/ is)
  • both (?)
@dkarlovi
Copy link
Author

dkarlovi commented Dec 1, 2021

Thinking about this further, sort by popularity might also not provide the correct behaviour for completion. For example, let's say you actually want laravue, you'd never get it because Laravel would always win.

Maybe we need a special search which returns just deduplicated namespaces, then we drill into the namespace with the name search? 🤔

@Seldaek
Copy link
Member

Seldaek commented Dec 2, 2021

A special vendor search type might be valuable anyway as it'd make the returned list quite a bit smaller.

@Seldaek Seldaek added the Feature label Dec 2, 2021
@dkarlovi
Copy link
Author

dkarlovi commented Dec 2, 2021

@Seldaek how would this work? Would Packagist need to get this as a feature and then Composer 2.3 detects / expects it? Not sure how the aligning with Packagist works here.

Seldaek added a commit that referenced this issue Dec 8, 2021
* Search performance improvements, add SEARCH_VENDOR type, fixes #10326, fixes #10324, fixes #10325

* Add extra optimization path for autocompletion of ^foo/* whereas the vendor is fully known, refs #10320
@dkarlovi
Copy link
Author

dkarlovi commented Dec 8, 2021

@Seldaek not sure this one should already be closed since it's discussing the sort too, which is AFAIK still in discussion?

@Seldaek
Copy link
Member

Seldaek commented Dec 8, 2021

I figured #10320 is enough as we'll need to solve problems there before merging it.

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 a pull request may close this issue.

2 participants