Sub topic 5
Finding Files by Name and Content
This chapter assumes you can open Spotlight with Command-Space, know where your documents and downloads usually live, and have seen the results list. It covers how Spotlight matches file names and file contents, how it ranks results, and why a file you expect sometimes fails to appear.
How Spotlight matches a file
Spotlight does not scan your disk when you type. It looks up your words in an index that macOS builds and updates in the background. Each file contributes two kinds of data to that index:
- Its name and other metadata, such as kind, dates, and author.
- Its text content, for formats macOS can read, such as PDF, Pages, Word, plain text, Markdown, and email.
A query can match either one. Typing invoice can return a file named invoice-march.pdf. It can also return a file named scan0042.pdf that contains the word "invoice" in its text.
Because the lookup uses the index and not the disk, results appear almost instantly. It also means a result is only as current as the index.
Searching by name
When you remember part of a file name, type that part. Spotlight matches words and the beginnings of words, so quar finds Quarterly Report.xlsx. It does not usually match text in the middle of a word, so terly finds nothing.
A few habits make name searches reliable:
- Use distinctive words.
budgetreturns many files, whilebudget 2026 draftreturns fewer. - Type words in any order.
report quarterlyfinds the same file asquarterly report. - Ignore capitalization and most accents.
resumecan matchRésumé.pdf. - Add the
name:keyword when you want only file names to count. For example,name:invoiceskips files that merely mention the word inside.
The name: keyword is useful when a common word appears inside many documents. Without it, a search for tax can fill the list with files that mention tax in passing.
Searching by content
Content search is what makes Spotlight different from a plain file-name search. If you remember a sentence from a document but not what you called it, type a distinctive part of it.
Suppose you wrote a proposal last month and remember the phrase "pilot in the northern region". Type those words and Spotlight lists documents containing them, even if the file is named Untitled 3.pages.
Content matching has limits you should know about:
- Scanned images and photos of text. A PDF made from a scanner may hold only a picture of the page. Spotlight can read text in many images on recent macOS versions, but results vary with image quality. Do not rely on it for old or low-resolution scans.
- Unsupported formats. Spotlight can read text only from formats it has an importer for. A custom or obscure file type may be indexed by name and date, but not by content.
- Encrypted files. A password-protected PDF or disk image exposes its name, but its text stays hidden.
- Very common words. Searching for
theormeetingreturns too much to be useful. Add more words or a kind filter, covered in later chapters.
Reading the result list
Spotlight groups results by category, such as Applications, Documents, Folders, and PDF Documents. It puts the item it considers the best match at the top. Ranking takes into account how closely the name matches, how recently and how often you opened the item, and where the match occurred.
Two practical consequences follow:
- A file you open often can rise above a closer name match. This is intended, but it can surprise you when two files have similar names.
- A name match usually outranks a content match. If you want to see content matches, scroll past the name hits or add words that appear only in the text.
Selecting a result shows a preview on the right. The next chapter covers previewing, opening, and revealing in Finder.
A worked example
You need a contract you signed last year with a supplier called Harbor Freight Logistics. You do not remember the file name.
- Press Command-Space and type
harbor logistics. Spotlight shows files with those words in the name or text. Several emails and a spreadsheet appear. - The list is too broad, so add a word you know the contract contains:
harbor logistics indemnification. Fewer results remain. - Select the top PDF and read the preview to confirm it is the right one.
- Press Command-Return to reveal it in Finder, so you can see which folder holds it.
This pattern works in most cases. Start with what you know, add a distinctive word to narrow the list, then confirm with the preview before opening.
Name and content together
Mixing a name word with a content word is a good way to cut the list quickly. Spotlight treats each word as a requirement, so name:contract harbor looks for files with "contract" in the name and "harbor" anywhere in the name or text. This is easier than guessing the exact title.
The following queries show the pattern. They are typed into the Spotlight field, not a terminal.
name:budget 2026
name:invoice acme
"pilot in the northern region"The first finds files with "budget" in the name that also mention 2026. The second finds invoice files that also mention Acme. The third uses quotation marks to match an exact phrase, which is covered in the chapter on operators.
Why a file might not appear
When a file you know exists does not show up, work through these causes in order.
| Cause | How to check | What to do |
|---|---|---|
| The file is new and not yet indexed | Wait a minute and search again | Indexing runs in the background and can lag after large copies |
| The folder is excluded | Open System Settings, then Spotlight, then Search Privacy | Remove the folder from the excluded list |
| The category is switched off | Open Spotlight settings and check the result categories | Turn on the category, such as Documents |
| The file is on an unindexed volume | Check whether the drive is a network share or has indexing off | Enable indexing on the drive, or use a different tool |
| The word is only in an image or unsupported format | Open the file and see whether the text is selectable | Search by name instead |
| The index is damaged or stale | Results are missing across many files | Rebuild the index, covered in the troubleshooting chapter |
Checking from Terminal
If you are comfortable with Terminal, mdfind runs the same index lookup and is a useful second opinion when the Spotlight window does not show a file. The -name option matches file names only.
mdfind -name "invoice"If mdfind finds the file and the Spotlight window does not, the file is indexed and the cause is a setting such as a disabled result category. If mdfind also finds nothing, the file is probably not in the index. The chapter on mdfind and mdls explains the command in full.
Common mistakes
- Typing the end of a word. Matching starts at the beginning of words. Type
quar, notterly. - Searching for a file type as a word. Typing
pdffinds files with "pdf" in the name or text. Use a kind filter to limit to PDFs. - Assuming a missing result means the file is gone. It often means the index has not caught up or a setting is hiding it. Work through the table above before concluding the file was deleted.
- Using one very common word. Add a second word or the
name:keyword. - Trusting the top hit blindly. Ranking favors files you open often. Check the path in the preview before you open or delete something.
Exercise
You remember that a report contains the sentence "customer churn fell in the third quarter", but you do not know its file name, and a search for churn returns more than 200 results. Describe two ways to narrow the search, and say how you would confirm the right file without opening it.
Show answer
First, search for the exact phrase by putting it in quotation marks, or add more distinctive words from the sentence such as churn third quarter. Second, add a name hint if you recall one, for example name:report churn. To confirm the file without opening it, select the result and read the preview pane, then press Command-Return to reveal it in Finder and check its folder and date.
Exercise
A PDF you scanned from paper is in your Documents folder. Searching for a sentence you know is on the page returns nothing, but searching for the file name finds it. Give two likely reasons for this.
Show answer
The PDF probably contains only a picture of the page with no text layer, so Spotlight has no words to index from it. Another possibility is that the text in the image was not recognized because the scan quality is low or the content has not been processed yet. Searching by name works because the name is indexed regardless of the content.