-
Notifications
You must be signed in to change notification settings - Fork 18k
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
x/pkgsite: searching exact standard library package names #64358
Comments
I could clone go.googlesource.com/pkgsite, analyze the code, run the server locally and observe how the stdlib is not always prioritized. However, I don't have the same datasources as production (postgres?) so a quick fix like "boost the Score of all stdlib results" might not be the best move. |
According to https://pkg.go.dev/search-help "If the package path you specified is complete enough, matching a full package import path, you will be brought directly to the details page for the latest version of that package." Directing to the stdlib package automatically may be too risky, but at least, I think we need to make it correctly considered as exact match and rank it the highest. |
Duplicate of #41369 |
Thanks @Deleplace for your careful investigation. Currently pkgsite search does not implement the documented rule: "If the package path you specified is complete enough, matching a full package import path, you will be brought directly to the details page for the latest version of that package." I'm not sure if that's really ideal, but this is actually a separate UI bug. As you can see below, the
The fix for this particular problem is to avoid demoting stdlib packages. Now does it make sense for a search of "path" to take you directly to pkg.go.dev/path? I say no. Then you could never search for general terms like "path", "sync" or "math". The rule may make sense for search terms with at least one |
I think the revised rule makes sense. Related, can "std" be special cased to be the standard library? it would help since it doesn't have a common module prefix to match against. |
I mailed a CL to address the problem with "path" being hidden by "path/filepath". Now all stdlib packages will be at top level. However, there may be more to do here:
I suspect these two have to do with the way we turn paths into tokens, which may be too delicate to tweak, but I'll look into that. (By "too delicate to tweak" I mean the amount of effort it would take to verify that changes to that algorithm do more good than harm exceed our work budget for pkgsite.) Lastly, there is the rule that search terms with a slash that match exactly should visit the matched package directly, skipping search, with a special case for "std". That one probably needs its own issue. |
Change https://go.dev/cl/643317 mentions this issue: |
Search will display all standard library packages at top level. Previously it grouped them based on the top-level directory, meaning that some could be hidden. For example, searching for "path" appears to omit the standard library package "path". In fact, it is nested under "path/filepath", which is more popular. With this change, "path" would appear second. Updates golang/go#64358. Change-Id: I2f35862ac514df0891b6f5b9055b6bf0a7ae37c7 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/643317 Reviewed-by: Robert Findley <rfindley@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> kokoro-CI: kokoro <noreply+kokoro@google.com>
https://go.dev/cl/644676 will implement the "std/" tweak to search queries, and document that queries without slashes don't redirect, even if they match a package. I looked into some of the other search concerns that @Deleplace mentioned in the top post. Here is a rundown on some of them:
|
What is the URL of the page with the issue?
https://pkg.go.dev/search?q=path&m=
What is your user agent?
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36
What did you do?
Searched the exact full name of a package of the standard library : "path"
What did you expect to see?
https://pkg.go.dev/path should be the first result
What did you see instead?
there are many results, but https://pkg.go.dev/path is not in the list at all
General problem
This is similar to #41369 but more specific: when exact search terms fail to show the relevant standard library package as 1st result.
The following rule should always hold:
IF a package exists in the standard library with name FOO, AND a user is searching the exact term "FOO" in pkg.go.dev, THEN the standard library package FOO must be the 1st result in the list
I tried 284 such searches, here are my findings.
The results of these 5 single-word searches are buggy:
The results of these 16 single-word searches are buggy too, according to the rule:
The text was updated successfully, but these errors were encountered: