Is there a RasPiOS version of Apple's SpotLight?

Nov 10, 2022 Last reply: 3 years ago 16 Replies

Probably wishful thinking on my part, but is there something akin to Apple's SpotLight file finder on RasPiOS? I know about find and grep -r, but those require operator skill and some patience.



Apt search locates mdfinder.app, but it's part of GNUstep and I think that's a whole separate GUI by itself.



Thanks for reading!



bob prohaska


find <starting point of search> -name <file name to search for>

Yes, it certainly does require some skill to use.

I've never had much to do with Apple stuff, so I just looked up "Spotlight MacOS" and it sounds much more like the "locate" command from GNU findutils, than "grep -r".

Personally I very rarely do whole-system file searches, so I just use "find -name" in particular directories. But locate should be much quicker for a system-wide search, you just have to run "updatedb" regularly.

formatting link

Correct me if I'm wrong, but I think locate (and find(1) ) search file

*names*, while Spotlight (and grep) search file *contents*. Spotlight knows how to interpret PDF, Word, etc files, not just plain text.

For similar searching of contents on Linux, there's an indexing library called xapian and various frontends, eg

formatting link
think some desktop environments build this in, not sure about PiOS)

I can't really recommend a frontend, in fact the only reason I know about Xapian is because I saw it eating CPU one day and worked out how to turn it off.

Theo

Yes. It also continuously maintains its index in response to file system events, so the searching is fast. find, locate & grep are not a great comparison.

Ah right, I didn't pick that up from skimming the Wikipedia page, but in that case it's quite different. It must gemerate a very big database if it covers file contents as well.

Ha! A utility that works about the same as grep but much faster is ripgrep which is in the RaspiOS repos under that name (so, sudo apt install ripgrep), or

formatting link
. It installs as 'rg' and there's a man page 'man rg'. Similarly, try fd-find as a replacement for find. It installs a binary called fdfind, for which I make an alias 'fd' but that could clash if you already have something called fd. Man fd and man fdfind both work out of the box, confusingly.

Apt info of ripgrep:

And fd-find:

I learned about those from

formatting link
which also had other useful things. Their git lecture was a bit crap; as always too slow at the start and then followed by "eh, this should've worked *clippety clop* ok I fixed it". And I hate them all jerking off to vim like they are in a secret society keeping the riff raff out.

Yes it does. With grep and friends you're doing the processing at the time of search, while with Spotlight and Xapian you're doing it ahead of time so that the search is faster.

The downside of building that database is it takes CPU cycles - which is fine for some use cases. Personally using laptops they are either in use on battery or sleeping, so there's no time when there are 'free' CPU cycles that don't waste battery. A Pi is probably less worried about that.

Theo

Its worth remembering 'apropos' for when you're looking for a command or library function to do a specific task. It searches manpage's heading lines for matching words and phrases, so its fast.

"apropos 'search tree'" returns 6 hits:

tdelete (3) - manage a binary search tree tdestroy (3) - manage a binary search tree tfind (3) - manage a binary search tree tsearch (3) - manage a binary search tree twalk (3) - manage a binary search tree twalk_r (3) - manage a binary search tree

in 79mS and they're all relevant manpages for functions you'd use to walk an in-memory binary tree structure.

I tried installing xapian-omega, since this is a desktop machine with lots of unused cpu time. The install seems successful, but I can't make heads nor tails of how to use it. Bash can't find an executable by that name, there's no manpage and no obvious additions to the main menu list. I also installed xapian-tools, which added more software but not obvious user interface.

Anybody got a hint? The machine is running buster. One inexplicable oddity is that the main menu icon is the Gnome footprint, which appeared unbidden after an upgrade a longish time ago.

Thanks for reading,

bob prohaska

additions to the

Just a generic solution: dpkg -L [package name] | grep /bin

You can also use "apt-file list" to list files in packages that aren't already installed (you may need to install apt-file).

That gave a hint to the doc files. Looks like xapian is a search engine intended for websites. Not quite what I was looking for, but maybe the only game in town. I'll explore further.

Thank you very much!

bob prohaska

xapian is a library for indexing files. Where you choose to use it is up to whatever frontend you use. I mentioned Recoll before, and:

sudo apt install recollgui recoll

and up pops up a dialogue saying 'do I want to index my home directory?'. I say yes, and then I can search for things - eg I searched for the word 'the' and it found it in a PDF in my Downloads.

Theo

Theo <theom+ snipped-for-privacy@chiark.greenend.org.uk> wrote: I mentioned Recoll before, and:

Indeed you did, and I missed it.

Recoll is indexing now.

Thank you!

bob prohaska

Yet another one, also available in RaspiOS : sudo apt install silversearcher-ag

Described as "very fast grep-like program, alternative to ack-grep"

The executable is called ag.

From the man page: "By default, ag will ignore files whose names match patterns in .gitignore, .hgignore, or .ignore. These files can be anywhere in the directories being searched. Binary files are ignored by default as well. Finally, ag looks in $HOME/.agignore for ignore patterns." "Use the -t option to search all text files; -a to search all files; and -u to search all, including hidden files."

Example ~/.agignore: .bash_history .fslckout

*.~* *.log *.pdf *.sqlite *.sqlite-shm *.sqlite-wal *.zip /fcgi/**/*ico /fcgi/**/*png /tmp/** /var/**

I use it via this alias: ag='/usr/bin/ag --context=1 --hidden'

Seems to work just fine. Amazing what rubbish chromium saves!

Thanks for your help!

bob prohaska

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required