Spotlight doesn't show .html file results

When I search for text in a .html file using the Command-Spacebar spotlight popup the .html file is never shown in the results. On the other hand the .html file does show in the result when I search in the Finder window search field, or when I search in the Terminal using mdfind.

Why is this and how can I fix? I want to use spotlight to find .html files.

You can reproduce the problem like this:

echo spotlighttest > testone.txt
% echo spotlighttest > testtwo.html
% mdfind spotlighttest       
2024-12-30 14:22:28.552 mdfind[28326:550500] [UserQueryParser] Loading keywords and predicates for locale "en_US"
2024-12-30 14:22:28.553 mdfind[28326:550500] [UserQueryParser] Loading keywords and predicates for locale "en"
~/Desktop/Spotlighttest/testone.txt
~/Desktop/Spotlighttest/testtwo.html

I believe this shows that both files are index properly, but if you then do Command-Spacebar and search for "Spotlighttest" I think you will see that only testone shows as a result.

Edit I believe this is a change in macOS 15.x and used to work correctly in previous macOS

A clue! If you search the spotlight popup with the following text:

kind:HTML AND "spotlighttest"

Then you will get the .html files shown. Yeah! But I don't understand why this is necessary for .html files and not for many other files types.

Do you get different results if the "Websites" item in Settings > Spotlight is on or off? Perhaps "Websites" is a new option in macOS 15? I can't remember if it was there before, but it might encompass .html files, too.

Do you get different results if the "Websites" item in Settings > Spotlight is on or off?

Alas no. Also it's not just .html, but other file formats as well. For example .opml files have similar behavior.

Okay, I'd say raise a bug, then post the FB number here.

https://feedbackassistant.apple.com/

Another clue, kind:HTML isn't the real difference, instead it's the fact that any text recognized as a metadata search takes a different path, and that path includes the .html files.

For example:

spotlighttest OR cantfindthis

Will also correctly include .html files. It's just when you type "spotlighttest" that .html files are not included in results.

I was alerted to the fact that when you search with a plain string in the spotlight popup the search is run as:

kind:Documents spotlighttest

So the new question: Where is it determined what file types are considered documents? Seems like one way to allow this would be to inherit from the right UTI type, but I don't see any "document" UTI types.

Any ideas?

Spotlight doesn't show .html file results
 
 
Q