Repository: go
Issue: x/pkgsite: searching exact standard library package names
Labels: pkgsite,pkgsite/search

### 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.

- When the full package name contains a "/" e.g. "compress/bzip", and the user is searching for the exact full name "compress/bzip", then no result list is displayed. Instead, the page is redirected to the correct stdlib package. **This works 100% of the time**
- When the full package name is a single word e.g. "time", and the user is searching for the exact word, then a result list is displayed. The correct stdlib package is most often the 1st result, with **5 annoying exceptions**
- When the full package name contains a "/" e.g. "compress/bzip", and the user is searching for the exact last word e.g. "bzip", then a result list is displayed. The correct stdlib package is often the 1st result, with **16 annoying exceptions**

The results of these 5 single-word searches are buggy:

Package | Search link | Result
-- | -- | --
path | [search path](https://pkg.go.dev/search?q=path&m=) | NOT FOUND
cmp	|  [search cmp](https://pkg.go.dev/search?q=cmp&m=) |  2nd pos
maps | [search maps](https://pkg.go.dev/search?q=maps&m=) | 8th pos
plugin | [search plugin](https://pkg.go.dev/search?q=plugin&m=) | 2nd pos
slices | [search slices](https://pkg.go.dev/search?q=slices&m=) | 4th pos


The results of these 16 single-word searches are buggy too, according to the rule:

Package | Search link | Result
-- | -- | --
runtime/coverage	| [search coverage](https://pkg.go.dev/search?q=coverage&m=)	| NOT FOUND
go/build/constraint	| [search constraint](https://pkg.go.dev/search?q=constraint&m=)	| 3rd pos
go/constant	| [search constant](https://pkg.go.dev/search?q=constant&m=)	| 3rd pos
go/doc/comment	| [search comment](https://pkg.go.dev/search?q=comment&m=)	| 6th pos
go/format	| [search format](https://pkg.go.dev/search?q=format&m=)	| 2nd pos
go/importer	| [search importer](https://pkg.go.dev/search?q=importer&m=)	| 2nd pos
go/types	| [search types](https://pkg.go.dev/search?q=types&m=)	| 4th pos
image/color	| [search color](https://pkg.go.dev/search?q=color&m=)	| 2nd pos
net/rpc	| [search rpc](https://pkg.go.dev/search?q=rpc&m=)	| 3rd pos
regexp/syntax	| [search syntax](https://pkg.go.dev/search?q=syntax&m=)	| 4th pos
runtime/cgo	| [search cgo](https://pkg.go.dev/search?q=cgo&m=)	| 2nd pos
runtime/metrics	| [search metrics](https://pkg.go.dev/search?q=metrics&m=)	| 21st pos
runtime/race	| [search race](https://pkg.go.dev/search?q=race&m=)	| 5th pos
runtime/trace	| [search trace](https://pkg.go.dev/search?q=trace&m=)	| 5th pos
testing/slogtest	| [search slogtest](https://pkg.go.dev/search?q=slogtest&m=)	| 2nd pos
text/template/parse	| [search parse](https://pkg.go.dev/search?q=parse&m=)	| 11th pos