Spotlight is terrible. But at the same time, very useful. Let's hope Apple cleans it up a bit in a future release. But until then, here is some more help - to go along with the tons of Spotlight hints we already have here.
Spotlight saved searches, or "Smart Folders," are simply XML files with a .savedSearch extension. Within that XML file, which you can open using any text editor, there is a tag called RawQuery; immediately following that is another called (ambiguously) string. The string tag right after the RawQuery tag is the "code" for your search.
Since Spotlight limits what you can put in the query in various ways, sometimes it is hard to get what you want out of it. Boolean searches are well documented both on this site and others -- but they prove problematic and inconsistent. So this hint is intended to share some info about how to modify the "code" in the saved search to get what you want.
Let me start with a scenerio. I have a bunch of images in a folder named Images, and I want to mark some of them as Oregon. So I use the Batch Spotlight Comment action in Automator to mark them as Oregon in the Spotlight comments. Then they are easy enough to find using Spotlight; just type in Oregon and there they all are. But say I add another batch marked Mountains, and I want to find all images that are marked Mountains but not Oregon. Not so easy to do with Spotlight, at least as the interface allows. If I open a saved search for Oregon-coded pictures, I get this XML (line breaks in the string line are added for readability; there are none in the code):
<key>RawQuery</key>
<string>(* = "Oregon*"wcd || kMDItemTextContent = "Oregon*"cd) &&
(kMDItemContentType != com.apple.mail.emlx) &&
(kMDItemContentType != public.vcard)</string>
Well, that code isn't too helpful. But Apple's Developer documentation on query syntax and what can be queried are good references. I will highlight the important stuff here for a simple overview, and in case they change the URL of the pages.
<key>RawQuery</key>
<string>(kMDItemFinderComment == "*oregon*"cd )</string>
The operators are:
<key>RawQuery</key>
<string>(kMDItemFinderComment == "*mountain*"cd &&
kMDItemFinderComment != "*oregon*"cd )</string>
Again, the line break in the string line was added for legibility; remove it when entering the text in the file.
Mac OS X Hints
http://hints.macworld.com/article.php?story=20051010171330457