May 11th, 2010 • 4:37 pm
Last week, I wrote about the fact that an exact phrase search in Spotlight fails to find plural forms when the searched string is a singular phrase.
Since then, Betalogue reader Brad L. has written to share a couple of additional bits of information.
The main one is that, as Brad has somewhat accidentally discovered (by using the search-as-you-type global Spotlight menu), it so happens that if you type a request for an exact phrase search but fail to include the closing quotation mark at the end, somehow Spotlight manages to find occurrences of both the singular and the plural forms of the phrase.
To use the example provided in my previous post, if you enter
“deep pressure technique
in the global Spotlight menu or in the search toolbar in the Finder, the results you’ll get will include occurrences of both “deep pressure technique” (singular) and “deep pressure techniques” (plural). On the other hand, if you enter
“deep pressure technique”
the search results will exclude occurrences of “deep pressure techniques” (plural).
Brad speculates that this might be an intentional feature of Spotlight, but I am not so sure. For one thing, it is particularly inelegant. It would make more sense if Spotlight supported some kind of “wildcard” character.
(Spotlight does support * as a wildcard character, but only when using raw queries.)
The other reason why I don’t believe it is intentional is that, while this works in the global Spotlight menu and in the Finder toolbar, it does not work in the search field in the Mail toolbar, which can be used for Spotlight queries limited to Mail messages, or in the Preview toolbar, which can be used for searching inside a specific PDF document.
(As noted in my previous post, in other applications, such as TextEdit and Pages, searching for the exact phrase “deep pressure technique” does return results that include both the singular and the plural forms.)
Brad also notes that, contrary to what I seemed to imply in my post, there is more than one option in current versions of the Spotlight user interface to restrict the search to file names. You can click on “File Name” in the search results window after the fact, but you can also include the “name:” prefix before your search query when you enter it in the global Spotlight menu or in the Finder toolbar.
If you don’t mind the extra typing and the extra hard drive churning and general sluggishness of the “search-as-you-type” interface while Spotlight needlessly searches for “na” or “nam” before you’ve finished typing, then this can be used as an alternative to the “File Name” button.
(Personally, I cannot stand the “search-as-you-type” interface, even on my fast 2009 Mac Pro, so I use LaunchBar‘s Spotlight interface, which lets me type my entire search request before it starts searching for matches.)
More generally, Spotlight supports all kinds of advanced options beyond the “name:” prefix. It also allows you to search by file kind and other attributes. The Mac OS X Hints web site has a PDF titled “Advanced Spotlight Menu Searches,” which is excerpted from David Pogue’s Missing Manual for Mac OS X and includes a more comprehensive list of options.
Finally, I should add that there does seem to be a solution to my initial problem, if you are willing to use raw queries. When I use the following raw query in a Finder window:
kMDItemTextContent=="deep pressure technique*"
the search results do include my PDF, which only contains “deep pressure techniques,” i.e. the plural form of the phrase. So it looks like the * wildcard also works for the
kMDItemTextContent attribute, and can be used to search for exact phrases in a way that does not exclude simple plural forms when the phrase you search for is a singular.
The search with such a raw query can be saved as a “saved search”/smart folder and reused, but this does have a number of drawbacks, including the fact that, when you reopen a saved search, the search criteria are hidden by default, so you have to make them visible first in order to be able to edit them, and then the text field to enter the raw query is not very wide and not adjustable, so there is a fair amount of scrolling horizontally within the tiny text field involved in order to edit the phrase you are searching for.
There might be a way to design a better interface for this with AppleScript, but that’s beyond my scripting skills at present.