Hey there,
For context, I have a script that (re-)generates several thousands of ODT and PDF files based on some template ODT files, starting with deleting the old ones. In practice, most generated files will quite often end-up being exactly the same as the previous ones (e.g. same hash, same modification date).
I noticed localsearch is consuming a tremendous amount of resources during and after this process, which is not surprising considering the amount of files deleted and then generated.
So I thought I’d somehow temporarily disable file indexing while the script is running. Since most files end-up being the same, I assumed pausing the Files miner would be the way to go. I was expecting that once it’s resumed, it would notice that only a few files have changed and quickly re-index these.
cookie=$(localsearch daemon --miner "Files" --pause "the reason" | grep "Cookie is" | grep -Eo '[0-9]+')
localsearch daemon --miner "Files" --resume "$cookie"
However, after being resumed, localsearch actually still consumes a tremendous amount of resources, contrary to what I was expecting.
I tried another approach: to entirely remove the top parent folder from the index while the script is running and then add it again. I was expecting this would require at least as many resources, since localsearch would have to delete and recreate from scratch the entire index for this folder.
localsearch index -d ~/the_top_parent_folder
localsearch index -a -r ~/the_top_parent_folder
Surprisingly, it uses several orders of magnitude less resources than the pause/resume approach!
Is there any reason? Is it because maybe, once resumed, the miner actually has to inspect every file in each and every indexed folder to check if it has changed? If that’s the case, I guess having the ability to pause the miner for a given indexed folder (or even better, for a specific path) would be the most optimal option.
PS: I struggled a bit to figure out how to pause/resume the miner which is mainly why I posted my commands, in case other people might find it useful. FYI, the command line documentation mentions an inhibit command which doesn’t seem to exist. As for the localsearch-daemon man page, it mentions a -l option which doesn’t seem to exist either.