EDITED: Is there a way to Nautilus for including certain files/folders in gnome's global search?

EDITED:
I have a folder that I named NSFW, inside the folder I have both .trackerignore and .nomedia files, yet other files inside that folder still appear in gnome’s global search.

phalkon@aerie:~/NSFW$ gsettings get org.freedesktop.Tracker3.Miner.Files ignored-directories-with-content
['.trackerignore', '.git', '.hg', '.nomedia']
phalkon@aerie:~/NSFW$ gsettings get org.freedesktop.Tracker3.Miner.Files ignored-directories
['po', 'CVS', 'core-dumps', 'lost+found', 'NSFW']
phalkon@aerie:~/NSFW$ ls -a
.  ..  .nomedia  .trackerignore  you_wont_find_me.jpg  you_wont_find_me.mkv  you_wont_find_me.txt

That said, these files seem to only get indexed after being opened. Files outside the NSFW folder get indexed almost right away without me having to open them first. Probably because they have been picked up by the tracker.

But since Nautilus will include files and folders not indexed by tracker, is there any way to prevent Nautilus from including certain files in the gnome’s global search?

Thanks

When you search in the GNOME Shell overview, the results are returned by Nautilus.

Do you see those files if you run tracker3 search on the commandline ?

You’re right, I’ll edit the original post to explain that the problem seems to be with nautilus, not tracker.

phalkon@aerie:~/NSFW$ tracker3-search you_wont_find_me
Results:

phalkon@aerie:~/NSFW$ tracker3-search you_wont_find_me.txt 
Results:

phalkon@aerie:~/NSFW$ tracker3-search you_wont_find_me*
Results:

But I thought Nautilus used tracker for the global search.

So how does Nautilus handle the global search and is there a way to exclude certain files/folders?

Nautilus’ search provider also queries the recently opened files (~/.local/share/recently-used.xbel) so if from within Nautilus you opened the you_wont_find_me files, they are in to the recently opened files list and consequently are in the search results.

My Documents directory and its subdirectories are set to be indexed in the search settings. As a test I created there:

  • TEST1 directory with .trackerignore and dont_find_me_1 files
  • TEST2 directory with .trackerignore and dont_find_me_2 files
  • TEST3 directory with just dont_find_me_3 file

Then I opened the Documents/TEST1/dont_find_me_1 file from Nautilus, closed Text Editor after. Then from overview doing a search for dont_find_me only finds the dont_find_me_1 file (from recently opened files list) and dont_find_me_3 file (from index, as it has no .trackerignore). It does not find the dont_find_me_2 file as that is not indexed and not in the recently opened files.

I suppose this is how it should work: Tracker (now LocalSearch) doesn’t index files in directories with a .trackerignore file and those are not returned by Nautilus’ search provider, but files you opened from Nautilus are returned as they are in the recently opened files list.

Yes, that seems to be it. Once removed from the recently-used.xbel, the files cannot be found via global search anymore.

It’s too bad that recently-used probably doesn’t have anything in terms of filter, where you could tell it to not bookmark certain files/folders.
But now that I understand where the problem is, I suppose I could write a script or something that would periodically remove unwanted bookmarks from recently-used.

Still I’d say it would be a good idea to add some kind of filter to recently-used, where the user could set files/folders that should not get bookmarked.
People might have files on their machines that for whatever reason they don’t want to pop up during global search.

There’s no granularity to it but in Settings > Privacy & Security you can disable File History (the recently used files list), change how long it remembers files, or clear it once.

FYI, there’s an open issue about Files in hidden folders are shown in Recent (#1503) · Issues · GNOME / Files · GitLab

That’s a little bit different issue. That talks about hidden files/folders.

However, it does seem like the global search won’t include files inside hidden folders. So that could work as a solution too.

But as the link suggests, hidden files/folders will still be in recently used, which you might not want either, that’s why I use this:

xmlstarlet ed -d "//bookmark[contains(@*, 'NSFW')]" ~/.local/share/recently-used.xbel > ~/.local/share/recently-used.xbel.tmp && mv ~/.local/share/recently-used.xbel.tmp ~/.local/share/recently-used.xbel

This will remove any bookmark that contains the string NSFW from recently used. I placed it in crontab and I suppose that’s good enough for me.