Spotlight

On this page 7

Spotlight is the system-wide search service of macOS that continuously indexes files, applications, emails, contacts and their metadata, so that anything on the Mac can be found and opened from a single search field, usually summoned with Command-Space. In macOS it is both a user-facing launcher and a background indexing service that Finder, Mail and other apps rely on.

Introduced with Mac OS X Tiger in 2005, Spotlight changed desktop search from scanning folders at query time to querying a prebuilt index, which returns results almost instantly. Recent macOS versions extended it from search into a command launcher that can run app actions, show clipboard history and perform calculations without opening another app.

How Spotlight builds and queries its index

Spotlight relies on a metadata server process called mds that receives notifications from the file system whenever a file is created or changed. Worker processes named mdworker then open the file, pass it to the matching metadata importer, and store the extracted text and attributes in an index kept in a hidden .Spotlight-V100 folder at the root of each indexed volume.

ComponentRoleVisible to users as
mdsCoordinates indexing and answers queriesProcess in Activity Monitor
mdworkerExtracts content from individual filesShort-lived worker processes
Metadata importersRead specific formats such as PDF or Office filesPlug-ins bundled with apps
Spotlight indexStores text and attributes per volumeHidden folder on each volume
Spotlight search windowAccepts queries and shows ranked resultsCommand-Space search field
Main components of Spotlight

Each file carries metadata attributes such as kMDItemContentType, kMDItemAuthors or kMDItemWhereFroms, which records the download source of a file. Because results come from the index, a search is fast but only as complete as the index; files on excluded or unindexed volumes never appear.

What Spotlight can find and do

Spotlight searches far beyond file names. It looks inside document text, email bodies, calendar events and contacts, and it can answer some questions directly in the results pane.

  • Launching apps by typing the first letters of their name.
  • Full-text search inside PDFs, Pages, Word and plain-text documents.
  • Calculations and unit conversions, such as currency or temperature.
  • Dictionary definitions and system settings panes.
  • App actions and clipboard history in recent macOS releases, for example creating a note or sending a message from the search field.
  • Online suggestions for web results, news and media when Spotlight Suggestions is enabled.

The search window and the Finder search field query the same index. Finder adds a visual query builder, while Spotlight favors quick keyboard-driven access.

Search syntax and command-line tools

Spotlight accepts attribute filters in natural form, which narrow results considerably. They can be combined with Boolean operators written in capital letters.

FilterExampleResult
kind:kind:pdf invoiceOnly PDF files containing the word
date:date:yesterdayItems modified yesterday
author:author:NovakDocuments with that author attribute
Boolean operatorsbudget AND NOT draftCombines or excludes terms
Exact phrase"quarterly report"Matches the words in order
Useful Spotlight query filters

Administrators and power users work with the index through Terminal commands, which expose the same engine for scripts.

CommandPurposeExample
mdfindSearches the index from Terminalmdfind -onlyin ~/Documents contract
mdlsLists the metadata of a filemdls report.pdf
mdutil -sShows indexing status of a volumemdutil -s /
mdutil -EErases and rebuilds an indexsudo mdutil -E /
mdutil -i offTurns indexing off for a volumesudo mdutil -i off /Volumes/Archive
Spotlight command-line utilities

Privacy settings and exclusions

Spotlight settings let users choose which result categories appear and which folders or volumes are excluded from indexing through a privacy list. Excluding a folder removes it from local search results, which is useful for large archives, virtual machine images or developer build folders that generate constant indexing work.

Local indexing stays on the Mac, but Spotlight Suggestions sends search terms and some context to Apple to return online results. Organizations with strict data rules often disable suggestions through a configuration profile while keeping local search, and users can do the same in System Settings.

Indexing scope also depends on the storage. Internal APFS volumes are indexed automatically, external drives usually are as well, while network shares are generally not indexed locally and depend on server-side search support. Time Machine backup destinations keep their own index so that past versions can be searched. Encrypted volumes are indexed only after they are unlocked, and the index is stored inside the protected volume.

Troubleshooting slow or missing results

Most Spotlight problems stem from a damaged or incomplete index, or from heavy indexing activity after a major upgrade or migration. During the first hours after installing a new macOS version, high CPU use by mds_stores is normal.

SymptomLikely causeFix
Known files not foundCorrupted indexRebuild with mdutil -E or the privacy list trick
External drive not searchableIndexing disabled or unsupported formatEnable with mdutil -i on
Constant high CPUFolder with rapidly changing filesExclude that folder from indexing
Old results after deleting filesIndex not yet updatedWait, or rebuild the index
Common problems and fixes

A simple rebuild method without Terminal is to add the affected volume to the Spotlight privacy list and then remove it again, which forces macOS to discard and recreate the index.

Stripped to the essentials

Spotlight is the search box for your whole Mac. Press Command and the space bar, type a few letters, and it shows matching apps, documents, emails and even quick answers like a calculation.

It works quickly because the Mac keeps a catalog of everything in advance, much like a library card index. Instead of walking through every shelf, Spotlight looks up the catalog and points straight to the right item. When you save or change a file, the catalog is updated quietly in the background, so new documents show up within moments.

Where it is applied

A project manager at an architecture studio needs a supplier contract signed two years ago but cannot remember the file name or folder. Typing kind:pdf Brennan warranty into Spotlight returns the signed contract in under a second, because Spotlight indexed the text inside the scanned and OCR-processed PDF.

The studio’s IT technician notices that several workstations show high CPU use. Running mdutil -s and Activity Monitor reveals that a rendering cache folder rewrites thousands of files per hour. The technician adds that folder to the Spotlight privacy list on every Mac through a configuration profile and disables Spotlight Suggestions according to company policy.

The result is fast, reliable local search for documents and a noticeable drop in background CPU load during rendering work.