Spotlight can't find some words

I scan quite a lot of old invoices etc, ocr them and save them as .pdf for archiving.


Doing some random tests, to check if the OCR works, I found out that Spotlight has a blind spot for some words.


You'd think they simple are not recognized correctly by the OCR software (PDFScanner), but a search in Preview finds any word I pick just fine.


Sometimes rescanning or even just re-OCR-ing a document fixes this, but with other documents, nothing seems to help.


If I select and copy the text from the pdf and paste it in a plain text file, Spotlight finds it just fine.


Using 10.14 Mojave, PDFScanner's latest updates.


Tips, anybody?

MacBook Pro 15″, macOS 10.14

Posted on Mar 12, 2023 2:51 PM

Reply
Question marked as Top-ranking reply

Posted on Mar 12, 2023 2:54 PM

Safe Boot, (holding Shift key down at startup), does the problem occur in Safe Mode? Could take 10 minutes.


Safe mode attempts to repair Disks & clears lots of caches & loads safe Drivers, & prevents loading of 3rd party extensions, so if Safe Mode works try again in regular boot.


Manually Rebuilding Spotlight via Terminal

If the aforementioned Spotlight control panel approach doesn’t spur a reindexation of the drive, you may need to initiate it manually through the command line. Open Terminal and use the following command string to do so:


sudo mdutil -E /

This basically asks for temporary super user status, which is why Terminal may ask you for your password (it may not if you’ve used a sudo command recently or are already logged in as a super user or root. The command asks the unix tool mdutil to reindex the spotlight database for everything on the computer, including external drives, mounted disk images, etc. To re-index only for a specific drive, use the /Volumes path. For example, for an external drive named “MiniMe,” the command would look like this:


sudo mdutil -i on /


Rebuilding a drive index can take a long time, so be prepared to wait whether you do it through the System Preference panel or the command line.


If still need be…


Open Terminal and run each of these one at a time


/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain system -domain user


sudo /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -seed -lint -r -f -v -dump -domain local -domain system -domain user -domain network


killall Dock


sudo mdutil -E /


sudo mdutil -i on /


Rebuilding a drive index can take a long time, so be prepared to wait whether you do it through the System Preference panel or the command line.

Similar questions

13 replies
Question marked as Top-ranking reply

Mar 12, 2023 2:54 PM in response to Leon Buijs

Safe Boot, (holding Shift key down at startup), does the problem occur in Safe Mode? Could take 10 minutes.


Safe mode attempts to repair Disks & clears lots of caches & loads safe Drivers, & prevents loading of 3rd party extensions, so if Safe Mode works try again in regular boot.


Manually Rebuilding Spotlight via Terminal

If the aforementioned Spotlight control panel approach doesn’t spur a reindexation of the drive, you may need to initiate it manually through the command line. Open Terminal and use the following command string to do so:


sudo mdutil -E /

This basically asks for temporary super user status, which is why Terminal may ask you for your password (it may not if you’ve used a sudo command recently or are already logged in as a super user or root. The command asks the unix tool mdutil to reindex the spotlight database for everything on the computer, including external drives, mounted disk images, etc. To re-index only for a specific drive, use the /Volumes path. For example, for an external drive named “MiniMe,” the command would look like this:


sudo mdutil -i on /


Rebuilding a drive index can take a long time, so be prepared to wait whether you do it through the System Preference panel or the command line.


If still need be…


Open Terminal and run each of these one at a time


/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain system -domain user


sudo /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -seed -lint -r -f -v -dump -domain local -domain system -domain user -domain network


killall Dock


sudo mdutil -E /


sudo mdutil -i on /


Rebuilding a drive index can take a long time, so be prepared to wait whether you do it through the System Preference panel or the command line.

Mar 13, 2023 1:30 PM in response to BDAqua

OK, meanwhile, I thought it would be a good idea to test this on another (also 10.14) machine (using the same files since they are syncronized via iCloud): Same results.


So then I copied one of the problematic, by PDFScanner created files to a completely different machine, different account, different macOS: Monterey 12.6.3. Still, the same problems. It doesn't seem to be the OS version either, although I didn't test Ventura. I have no access to a machine with macOS 13.


I'm a bit on the end of my rope here.


For some reason PDFScanner pdf's are not indexed correctly, even though the text seems correctly OCR'ed.


I mailed the author, but he had no idea either.

Mar 19, 2023 2:20 AM in response to BDAqua

No. It all looks like gibberish. You can find some more or less real words like FontElement and the name of the app that created it, if you scroll through the first and last part of the file, but you can't find any words, like you can in a pdf-viewer. I tried to find the word Goltix, for example, that is in the pdf, but I can't find it in the code. Not in plain text, not in hex, not in hex + 00 type of code. I saw my name because it's the account name of the user that created this file, but that's in plain text. Tried if I could also find it with the search option – yes – just like the FontElement word, but that's about it.

Mar 12, 2023 4:53 PM in response to BDAqua

Thank you. I didn't expect an answer so soon.


I did a Safe Boot. It didn't even take that long. Maybe a minute or so longer than usual. Sportlight didn't seem to work after that, so after a few minutes I did a regular restart.


When I try to use Spotlight now, I can see that it is indexing. Finished in about 5 minutes.


Spotlight works again, but still has the same blind spot. It's really weird. It finds a certain word in one OCR-ed pdf, but not in another. The pdf's really contain the word, because if I open them in Preview, I can highlight them by typing them in the search window.


So I tried /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain system -domain user


in Terminal but it returns: System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister: No such file or directory


Should I choose between -domain local, -domain system and -domain user instead? Use my username instead of 'user'?


Thanks for trying to help me :)

Mar 18, 2023 4:36 AM in response to BDAqua

Interesting. Didn't know Hex Fiend yet. I can open a pdf with it, but it show only 8-character hexadecimal code. I guess this is how the file is saved on a lower level.


I can search the contents, but it doesn't find the keywords, not in text mode either, nor when I search for the words in hex form.


Do you think there might be an app that I can analyse a pdf with, to check out if the pdf's are broken in some way?


The author of the app responded that years ago, there appeared to be a problem with the Dutch setting of the OCR, but that was 'a few years ago' so this doesn't explain why this would still occur, nor with the English setting active.


He also wrote: "Spotlight can be picky, but if you find the text in preview, i don't see why Spotlight wouldn't find it."

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Spotlight can't find some words

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.