1

Folks, does anybody understand how the Finder (= Spotlight) search really works?

Test 1

I have created the following test files and folders in my $HOME:

~/ |- test0/ - regular folder |- test1.txt - hidden with `chflags hidden test1.txt` |- .test2.txt - dot file |- .test3/ - dot folder |- test4.txt - regular file 

If I open Finder and look for test, the test1.txt file is successfully found (despite it is hidden!) without any tweaks (fig. 1).

enter image description here

But there is no way — at least, I didn't figured it out myself yet — to show .test2.txt, .test3 and test4.txt. At first glance, the solution is easy: click a search criteria, select "Other", there enable the "File invisible" check box, then add it as a new criteria (fig. 2).

enter image description here

But this doesn't help. And even worse, even test1.txt is not found then. In fact, this option seems to broke any search — no matter which files you tried to search, the search won't find anything.

Test 2

I have a test file called foo in my /usr/local/bin. Finder cannot find it, even if (the same as the second step in Test 1) I will add "System files" criteria (fig. 3).

enter image description here

Questions

  • Q1: Does it work the same for you?
  • Q2: Is it a known bug? If "yes", could you provide a link?
  • Q3: Is there a fix or workaround for this? I'm not afraid of using command line.

Thanks in advance! Yes I know about third-party search utilis. Please don't mention them, let's keep it focused.

2
  • I think that Spotlight still excludes quite a lot of system stuff, including unixy things, even if you've asked to include "System files". Commented Mar 13 at 12:58
  • @benwiggy But then another question. If I have "System files = are included", then which files and folders are included exactly? In other words, for what this setting is used for exactly? Commented Mar 13 at 14:02

1 Answer 1

3

The spotlight system is an indexed search system designed for fast access, but it doesn't index everything (assumedly to avoid spamming the user with search results they will almost never need).

Files that start with dot (e.g., ~/.test.txt) are considered to be system or app data files that the user never wants to see, so they are not indexed by spotlight.

Files that are software hidden using chflags hidden are indexed by spotlight, but not shown unless requested.

The 'system files' option in a spotlight search will extend search results into the ~/Library folder, but not into the root system. Root system folders are not indexed by spotlight.

If you want full search access, there are apps available on the app store that will do non-index searches. These take a lot more time (obviously), but are thorough. I've habitually used EasyFind (DEVONTechnologies) but for some reason that's not on the App Store. Go figure…

14
  • 1
    @johnm: files hidden with a dot are not indexed, and will never show up in a spotlight search. Files that are software hidden using chflags hidden are indexed, and you can use the 'file visibility' to include, exclude, or focus on those files. so if you have a folder with a bunch of visible files and a bunch of chflags hidden files, you can search only the hidden ones, only the visible ones, or all of them, as you choose. Commented Mar 13 at 16:20
  • 1
    @johnm: Interesting. That feature seems to be broken. I don't know whether that's a finder bug or a spotlight bug; I'll have to try some raw 'mdfind' queries in terminal, and I don't have time for that right now. I'll check later. Commented Mar 13 at 20:33
  • 1
    Well, I'm on sequoia too, and I can't get the 'file visibility' thing to work even in mdfind queries (kMDItemFSInvisible == 0). It's busted; someone should file a bug report. Commented Mar 14 at 7:05
  • 1
    @johnm "How it can be fixed" - I'm going with feedback to Apple. Commented Mar 14 at 8:44
  • 1
    I did, yes..... Commented Mar 14 at 14:58

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.