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

x/pkgsite: improve search ranking heuristics or add a way to search by package name #51775

Open
cespare opened this issue Mar 17, 2022 · 2 comments
Open
Labels
NeedsInvestigation pkgsite/search pkgsite

Comments

@cespare
Copy link
Contributor

@cespare cespare commented Mar 17, 2022

What is the URL of the page with the issue?

https://pkg.go.dev/search

What did you do?

I searched for constraints, slices, and maps on pkg.go.dev in hopes of finding golang.org/x/exp/constraints, golang.org/x/exp/slices, and golang.org/x/exp/maps.

What did you expect to see?

Since I'm searching for the exact package name, and the packages I'm looking for are from golang.org, I would expect my desired results to be near or at the top of the search results.

What did you see instead?

For constraints, the search worked pretty well. golang.org/x/exp/constraints was the second result.

screen_20220317141503

The first place result doesn't actually say "constraints" in the package name, import path, or top-level doc comment, but it does contain the word "constraints" in the README as well as a Constraints type.

For slices the search worked less well -- golang.org/x/exp/slices was the 16th result. Most of the first 15 results do not contain the word "slices" in the import path; typically it appears in the README or documentation text.

When searching for maps, golang.org/x/exp/maps doesn't even appear on the page. I have to hit "Show more results" and then the package is number 59.

I think these search results could be improved. For a start, if the search query exactly matches the package name, I think that should push the ranking up a lot higher. Also, I think that golang.org packages ought to rank pretty highly in general.

As an alternative to changing the ranking, the search page could provide a special syntax for searching by exact package name. I appreciate that when I put in a full import path, it takes me directly to the page for that package -- but typing out golang.org/x/exp/maps is pretty tedious, so being able to type something shorter like /maps and get shown a list of packages named "maps" would be pretty helpful.

Finally, FWIW, a general comment about how I use the pkg.go.dev search functionality. One kind of search (we could call it a "discovery search") is where I type in a search concept hoping to find a list of popular packages related to this concept. For instance, I might type "b-tree" and hope to find the popular packages implementing a B-tree. This seems to be the main kind of searching that pkg.go.dev is optimized for. For me, these kinds of searches are exceedingly rare -- <1% of my search volume. For most searches, I know exactly the package that I want to call up, and I'm trying to get to the page as efficiently as possible, and I feel that the search tool could help me more in this regard.

@gopherbot gopherbot added this to the pkgsite/search milestone Mar 17, 2022
@seankhliao
Copy link
Contributor

@seankhliao seankhliao commented Mar 17, 2022

As far as I can tell, the suggested syntax already works, as described by search help

/constraints does show packages ending in /constraints, and you can also search by partial match, eg exp/constraints

@cespare
Copy link
Contributor Author

@cespare cespare commented Mar 17, 2022

@seankhliao oh, very good point. I hadn't considered that including a slash in the query is unlikely to match text apart from the import path.

However, the results of searching for /constraints, /slices, and /maps are pretty odd.

/constraints doesn't turn up golang.org/x/exp/constraints at all, for some reason.

screen_20220317152034

Though, as you pointed out, exp/constraints gives me exactly what I want:

screen_20220317152126

Similarly, searching for /slices and /maps doesn't turn up golang.org/x/exp/slices and golang.org/x/exp/maps at all, even if I hit "Show more results".

@jamalc jamalc added the NeedsInvestigation label Mar 18, 2022
@hyangah hyangah added the pkgsite/search label May 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation pkgsite/search pkgsite
Projects
None yet
Development

No branches or pull requests

5 participants