Searching by name
One field, one job: it narrows the grid by file name, as you type.
Opening it
The magnifying glass in the titlebar opens the field. ⌘F opens it and puts the cursor in it, which is the way to use it without reaching for the mouse.
The list narrows as you type. Empty the field, or click the small cross at its right end, to see everything again. Once it is empty and you click elsewhere, the field closes on its own.
What it looks at
The file name, and only the file name. Upper and lower case make no difference, and part
of a name is enough: typing img finds IMG_4021.HEIC.
It does not look at the contents of the file, and it does not look at the folder the file is in. If you are trying to find everything from one subfolder, the search field is the wrong tool — scan that subfolder instead.
Together with the filter
Both narrow the list at the same time, and the count under the window title reflects both. Anything they hide is also left out of Select All — see Selecting items.