Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.4: Use Boolean (NOT, OR) searches in Spotlight System 10.4
Tiger only hintThere's limited (and undocumented) support for boolean queries in Spotlight. After experimenting a little, I found the syntax for OR and NOT.
  • lenin|trotsky will find documents mentioning either Lenin or Trotsky
  • lenin(-stalin) will find documents mentioning Lenin, but not, thankfully, Stalin
  • lenin|trotsky(-stalin) will find documents mentioning either Lenin or Trotsky, but not Stalin
For more details, check this article on my site.

[robg adds: This is the first I've heard of using a minus sign to get a NOT functionality directly in the Spotlight bar. The comments on the linked site (note that it was very slow to load when I tested it) add a bit more detail...]
    •    
  • Currently 2.50 / 5
  You rated: 1 / 5 (10 votes cast)
 
[48,286 views]  

10.4: Use Boolean (NOT, OR) searches in Spotlight | 25 comments | Create New Account
Click here to return to the '10.4: Use Boolean (NOT, OR) searches in Spotlight' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.4: Use Boolean (NOT, OR) searches in Spotlight
Authored by: jacobolus on May 12, '05 11:55:13AM

The behaviour on thie one is just weird. When I use the | symbol, it no longer returns files with the desired words in their names, only in content. I'm not sure about other metadata. So if I have a folder named "fishy cat", and I search for fishy|cat, the folder doesn't show up!



[ Reply to This | # ]
10.4: Use Boolean (NOT, OR) searches in Spotlight
Authored by: toupsz on May 12, '05 01:26:03PM

It's evidently exclusive, not inclusive, or then. Basically, you'd use it to specify alternatives, i.e., cat|kitty would mean "I want things that are either cat or kitty, but not both."
-Zach



[ Reply to This | # ]
10.4: Use Boolean (NOT, OR) searches in Spotlight
Authored by: steresi on May 12, '05 01:44:07PM
If it's an "exclusive OR", then would this bring up the "fishy cat" folder?
fish|cat|(fish cat)
Is the syntax correct? I'm trying to write "fish OR cat OR (fish AND cat)"

[ Reply to This | # ]
10.4: Use Boolean (NOT, OR) searches in Spotlight
Authored by: PancakeMan on May 12, '05 02:03:55PM

You're right, that IS weird behavior! What on earth would you keep in a folder named "fishy cat"?

;-P



[ Reply to This | # ]
10.4: Use Boolean (NOT, OR) searches in Spotlight
Authored by: siaraX on May 22, '05 02:01:03PM

this is becuse space and pipe | are different characters.

I think this hint is more for search of the text in the files
so if you have file abc.txt and inside you have word cat fish
if you use cat|fish it will fetch this file

but if you have two files
where in second one you have extra dog if u don't use -dog
u will see two files as result



[ Reply to This | # ]
10.4: Use Boolean (NOT, OR) searches in Spotlight
Authored by: John Derwent on May 12, '05 01:25:26PM

And quotes around a phrase appear to give an exact phrase search.

---
jed



[ Reply to This | # ]
10.4: Use Boolean (NOT, OR) searches in Spotlight
Authored by: denckwanzer on May 12, '05 01:43:06PM

This seems to work in Mail.app, too (in both the Mail spotlight search and for smart mailboxes). You can also do more complex boolean searches like "name|name(-company)(-place)". I was really needing something like this!



[ Reply to This | # ]
Create an AND using ORs and NOTs
Authored by: Gabriel on May 12, '05 02:50:43PM

Here's a way to get an AND using only ORs and NOTs
If I remember my logic correctly DeMorgan's law states that

A AND B = (NOT ((NOT A) OR (NOT B)))
This basically means that if either A or B is false than the whole statement is false, which is the same as saying A AND B is true. So assuming that spotlight doesn't support ANDs you can create one by saying:

(-((-fish)|(-cat)))

Unfortunately I don't have my mac with me to test this - hopefully Spotlight supports nested statements.



[ Reply to This | # ]
Create an AND using ORs and NOTs
Authored by: lallmen on May 12, '05 03:39:03PM

Just out of curiosity, why do not simply use:

fish&cat



[ Reply to This | # ]
Create an AND using ORs and NOTs
Authored by: strikeman on May 12, '05 08:42:47PM
The default behaviour is AND ie typing
fish cat
is the same as
fish AND cat


[ Reply to This | # ]
It works, but it's kludgy
Authored by: Lectrick on May 13, '05 12:17:52AM

Either it works (I checked), or it's just doing a straight-up AND between "fish" and "cat" and ignoring the rest...

an AND is simply a space, of course.

---
In /dev/null, no one can hear you scream



[ Reply to This | # ]
10.4: Use Boolean (NOT, OR) searches in Spotlight
Authored by: jcroft on May 12, '05 02:57:15PM

It seem this only works with content searches. I can't get it to work with images. For example, I'd like to be able to say:

michelle(-breckenridge) kind:image

And find all images of Michelle that weren't taken at Breckenridge. However, as soon as I do the not syntax, it stops showing image results, and sticks to documents, e-mails, etc. Anyone get this working for images?



[ Reply to This | # ]
10.4: Use Boolean (NOT, OR) searches in Spotlight
Authored by: jacobolus on May 12, '05 03:20:57PM
Let me clarify my earlier remark. The raw query syntax for a search on, say,
mac|hints
will be something like:
* = "mac|hints*"wcd || kMDItemTextContent = "mac|hints*"cd
As far as I can tell, this only picks up "mac OR hints" in the text content. I think the "this|that*" syntax doesn't work for other fields, and finds nothing.

So if you want to search only through text contents, then this method works okay. If you're looking for filenames, image keywords, or anything else, you're out of luck. It won't even find a folder named "mac hints"

Also, I'm not sure of this, but I think that probably it will still find any word that begins with the word/fragment/prefix of whatever the last word is in the query, but it may not work for the word before the |, as there's no longer a * after it. And you can't add a * to the query, as spotlight escapes such characters automatically: "\*" will show up in the raw query.

[ Reply to This | # ]

10.4: Use Boolean (NOT, OR) searches in Spotlight
Authored by: jacobolus on May 12, '05 03:22:47PM

that last should be "\*", not "*"... silly html formatting away my backslash



[ Reply to This | # ]
10.4: Use Boolean (NOT, OR) searches in Spotlight
Authored by: Usuario on May 12, '05 11:04:40PM
It doesn't works for me. If I add ( or | I get this message: No Results Found.
Any word or letter before | or ( get same message.
You can see this movie
This is my configurationin Spotlight.

[ Reply to This | # ]
10.4: Use Boolean (NOT, OR) searches in Spotlight
Authored by: Lectrick on May 13, '05 12:13:40AM

I checked your movie (what app does that, btw? nice movie!)

Why don't you try actually finishing the whole statement first, before giving the results significance? For example, you never closed your parentheses and you never typed anything after the | . I would imagine that an "incomplete" search query would return nothing.

---
In /dev/null, no one can hear you scream



[ Reply to This | # ]
10.4: Use Boolean (NOT, OR) searches in Spotlight
Authored by: Usuario on May 13, '05 02:02:42AM

Yes, you right!!!. Tank you. "Snapz Pro X 2 w/ movies" was the app used for the movie.



[ Reply to This | # ]
10.4: Use Boolean (NOT, OR) searches in Spotlight
Authored by: JoolsG4 on May 13, '05 01:36:17PM
Found this in Mac Help:

You can also use special characters to further refine your search. Type a + character to find pages that include all the words you enter.

Type ! to exclude a word. "video ! sound", for example, finds pages with the word video that do not have the word sound.

Use () to group items. The search "(video | movies) ! sound" finds pages that mention video or movies, but don't mention sound.

[ Reply to This | # ]

10.4: Use Boolean (NOT, OR) searches in Spotlight
Authored by: Dunbar on May 16, '05 01:05:26PM
Type a + character to find pages that include all the words you enter.
What's the syntax for that, Jools? I can't get it to work. It just gives me the same results as using spaces.

[ Reply to This | # ]
10.4: Use Boolean (NOT, OR) searches in Spotlight
Authored by: Dunbar on May 17, '05 05:42:57PM

Hello again, Jools. The Help you quoted above is actually referring to using Help and not to Spotlight.



[ Reply to This | # ]
10.4: Use Boolean (NOT, OR) searches in Spotlight
Authored by: quentinsf on May 15, '05 06:37:19AM
The Mail search box seems to have different rules, at least when searching certain fields. I want a list of all messages from either Fred or Bob, but I haven't found a syntax which works.

I can do it with a Smart Mailbox, of course.

[ Reply to This | # ]

10.4: Use Boolean (NOT, OR) searches in Spotlight
Authored by: tluger on May 21, '05 12:52:28AM

I found this little app that allows full use of ALL normal boolean operators. It seems to access spotlight for file contents cause it worked 2 seconds after installation.

http://www.grunenberg.com/easyfind.html

just put in the apps folder and open. then select file contents and operators from the SIMPLE GUI and choose your folder. Let me know if it works for the rest of you as it seems to do for me.



[ Reply to This | # ]
10.4: EasyFind
Authored by: Zo-1 on Jun 18, '05 08:06:33PM
Nooo. . .EasyFind has always worked like that.

The reason it's so fast? That's DEVONTechs' little trade secret!

Fanstastic, isn't it! (Just a fan.) (Who can't believe how many people don't know about Devon . . . yet.)


[ Reply to This | # ]
10.4: Use Boolean (NOT, OR) searches in Spotlight
Authored by: jwtheiss on Aug 05, '05 12:37:36PM

After much frustration, I went to the Devon (makers of EasyFind) forum. Unfortunately, their boolean operators only work on complete words, so if you're trying to strip out results with just characters in the filename, it's a no-go (unless what you're stripping out is a whole word in which case I'm assuming it works fine - just not for my needs).

I really can't believe that Apple didn't include a "does not contain" filter in both spotlight and the new Find dialog. I've got a folder of about 24k files that I need to be able to delete all the ones with XXX but not with YYY in their filename. 24k files is quite a bit to do by hand...



[ Reply to This | # ]
10.4: Use Boolean (NOT, OR) searches in Spotlight
Authored by: jwtheiss on Aug 05, '05 01:48:39PM

Update: just got another post from the Devon board and EasyFind does support substrings with the ~ character.

So, to find files with XXX but not YYY in the filename would look like this:

~XXX but not ~YYY

Would recommend EasyFind to anyone who needs boolean searches for filenames.



[ Reply to This | # ]