2

Spotlight has a quirk that I want to fix, if possible. When I search for certain keywords, such as categories in System Preferences, Spotlight will place a document as the "Top Hit" in the search results, even though System Preferences have a higher priority over Documents in Spotlight's preferences. I want to be able to blacklist certain filetypes while preserving the "Documents" category.

For example, typing "sharing" will return the top hit as "sharing.qml" from the Qt5.1.1 directory, followed by Sharing in System Preferences. I can't then immediately press enter to open "Sharing" without first pressing the down arrow.

Sharing with incorrect ordering of results


What I am able to do to fix this individual issue is blacklist the Qt5.1.1 examples directory.

Second incorrect result

You can see that it returns "sharing.html" from the gtk-doc directory now. So I blacklist that directory as well.

Finally

Now I am able to search for "Sharing" with no issues. However, there are other search results that exhibit similar behavior, such as when typing "mouse". It is too tedious to block each directory that I find.

I don't want a rkt file


Settings for Spotlight


I want to be able to blacklist individual filetypes from Spotlight. I have set "System Preferences" to have a higher priority than "Documents" in Spotlight as well. Nothing seems to affect the "Top Hit" other than individually blacklisting each directory that holds a file that I don't want to see.

Is there a better way?

2
  1. Find the importer used to import that type of file.

    mdimport -d 4 -n /path/to/file 2>&1 | grep Imported

    mdimport -d 4 -n ~/Desktop/avatar.png 2>&1 | grep Imported
    2014-06-19 11:17:04.929 mdimport[30911:412893] Imported '/Users/grgarside/Desktop/avatar.png' of type 'public.png' with plugIn /System/Library/Spotlight/Image.mdimporter.
    

    The above example shows the type as public.png in the Image.mdimporter importer.

  2. Open /path/to/importer/Contents/Info.plist in an editor.

  3. Find the item of the same type as the type of the file that you found from the above command and delete it.

  4. Reimport the importer.

    mdimport -r /path/to/importer

    mdimport -r /System/Library/Spotlight/Image.mdimporter
    

Don't forget to have backups and note this procedure may be overridden on OS X updates.

  • This looks like it should work. However, the command with grep Imported does not output anything for either the path for sharing.qml or mouse.rkt. – aglasser Jun 19 '14 at 14:07
  • @aglasser What do you get if you run the command without the pipe? Just try running this: mdimport -d 4 -n /path/to/file 2>&1 – grg Jun 19 '14 at 16:27
  • Ah, I am foolish. I should have tried that before. It was because there are spaces in the path to each file... Escaping them works now. Thanks for your insight. I will try the entire process and get back to you if it works or not! 2014-06-19 12:31:00.382 mdimport[18293:507] Imported '/Applications/Racket v5.3.6/collects/frtime/demos/mouse.rkt' of type 'org.racket-lang.source' with plugIn /System/Library/Spotlight/RichText.mdimporter. – aglasser Jun 19 '14 at 16:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .