Sub topic 10
Finding items with search
This chapter covers how Finder search works and how to control what it searches. It also covers how to narrow the results and what to check when an item you know exists doesn't appear. It assumes you can already open a Finder window, move between folders, and have read the earlier chapters on the sidebar and tags.
How Finder search works
Finder doesn't scan your disk when you type. It queries the Spotlight index, a database macOS builds in the background. The index stores file names, file types, dates, tags, and the text inside many documents. A search returns results from that database almost instantly.
The same index powers the Spotlight menu, smart folders, and the mdfind command. A problem in the index therefore affects all of them.
Starting a search
There are two ways to begin.
- Click the search field at the top right of a Finder window and type.
- Press Command-F while a Finder window is active. This moves the cursor into the search field and keeps your current folder as the starting point.
As you type, Finder offers suggestions beneath the field. These include "Name matches", "Name contains", and "Kind" suggestions. Choosing a suggestion makes the search more specific than plain text.
- Plain text matches file names and, for supported file types, the text inside files. Searching
invoicecan return a PDF that never mentions "invoice" in its name. - Name matches limits the search to file names only. Use it when content matches add noise.
- Kind suggestions limit results to a type, such as Image, PDF, or Folder.
Choosing the scope
Below the search field, a bar shows the places Finder can search. Look at it before you trust any result.
| Scope button | What it searches | When to use it |
|---|---|---|
| This Mac | Every indexed location on the Mac | You don't know where the item lives |
| Current folder (named after the folder) | The folder you started in and its subfolders | You know the project or area |
| Shared | Connected network locations, if any | You work with a file server |
The default scope is set in Finder Settings, under Advanced, in the option "When performing a search". The choices are Search This Mac, Search the Current Folder, and Use the Previous Search Scope. If your searches return too many unrelated files, check this setting.
Narrowing results with criteria
Once a search is running, a + button appears under the scope bar. It adds a criteria row. Each row has an attribute on the left and a value on the right, and Finder combines all rows with AND. An item must satisfy every row.
Useful attributes include:
- Kind, such as Document, Image, or Folder.
- Last opened date, Created date, and Last modified date.
- Name, with options such as "contains", "begins with", and "ends with".
- Tags, if you pick it from the Other list.
For example, to find last month's PDFs about a project:
- Press Command-F and type the project name.
- Click This Mac or the project folder in the scope bar.
- Click +. Set the first row to Kind is PDF.
- Click + again. Set the second row to Last modified date is within last 30 days.
Hold Option while clicking + to turn a row into a group where you can pick any/all/none logic. That takes you past simple AND matching.
The search field also accepts typed shortcuts such as kind:pdf and name:budget. You can write several, for example kind:pdf budget.
Acting on results
A results list is a normal Finder window. You can:
- Press Space to preview an item with Quick Look.
- Press Command-I to see its Get Info panel.
- Press Command-R to reveal an item's containing folder, which also works from an alias. If the results are showing, you can instead right-click and choose Show in Enclosing Folder.
- Switch to List view and add the Kind and Date Modified columns to tell near-duplicates apart.
The Path Bar is useful here. Choose View > Show Path Bar, then select an item in the results. The path appears at the bottom of the window, so you see exactly where a match sits.
Searching from Terminal
mdfind queries the same index from Terminal, which helps with scripting and with checking results.
mdfind -onlyin ~/Documents -name "invoice"This lists files in Documents whose names contain "invoice". To search by tag instead, use the metadata attribute the Finder uses internally:
mdfind -onlyin ~/Documents "kMDItemUserTags == 'Urgent'"Both commands return full paths, one per line. If Finder and mdfind disagree, the cause is usually the scope or the index, not the command.
Common errors and fixes
The file exists but doesn't appear. Check these in order:
- The scope is set to a folder, not This Mac.
- The file is in a hidden folder or the Library. Spotlight skips hidden items by default.
- The folder is excluded. Open System Settings, go to Spotlight, then Search Privacy, and look for the folder or drive in the list. Remove it to allow indexing.
- The file is new and the index hasn't caught up, or the disk is still being indexed after an update.
Results are out of date or missing in bulk. The index may be damaged. Check its status:
mdutil -s /The output should say "Indexing enabled." If it doesn't, ask an administrator to re-enable indexing before you try to rebuild it. Adding your disk to Search Privacy and then removing it makes macOS rebuild the index. This can take hours on a large disk, and search results stay incomplete until it finishes.
Too many results. Plain text matches contents, so common words match many files. Use Name matches, add a Kind criterion, or narrow the scope.
Content search misses a file. Spotlight reads text only from file types it has an importer for. Scanned PDFs without recognised text and unusual formats are searched by name only.
Exercise
Exercise
You search for "budget" with the scope set to This Mac and get hundreds of results, most of them emails and web pages. List three changes in Finder that would narrow the results to spreadsheets you edited this week.
Show answer
Any three of these: choose the "Name matches" suggestion so only file names are matched; click + and set Kind to Spreadsheet; click + again and set Last modified date to within the last 7 days; change the scope from This Mac to the folder where you keep work files.
Exercise
A file you saved yesterday in ~/Documents/Archive never shows up in search, although you can see it in the folder. Name two likely causes and one command that helps you check.
Show answer
Likely causes: Archive (or Documents) is listed in Spotlight's Search Privacy list, or the index is disabled or still rebuilding. Running mdutil -s / shows whether indexing is enabled. You can also run mdfind -onlyin ~/Documents/Archive -name "filename" to see whether the index returns the file.