I would do the search on a backup drive. If you don't have backups, then you're living pretty dangerously.
Are you wanting to search the interior of files, like find all the documents with "tax" in them? or are you wanting to find where you put the file whose name is "2022 Taxes?" For the later, for instance, I have lots of backup drives, and when I want to find the path to which folder in which drive holds this file (often several of them) I use an app called "Offline Disks File Searcher" which I have had index all those disks. There are others on the App Store, but I doubt any of them can do a search of iCloud Drive, or even index iCloud Drive files that aren't local. It's worth a look, but I'll bet there are no 3rd party apps that can search non-local iCloud files, since it might violate their security.
I think this is an interesting question-- searching inside iCloud files. iCloud Drive is designed to hold files that you want to be able to access and use from multiple devices, and active files are meant to be kept local-- so the files likely to change should be kept on the computer. Archive files can the on external drives.
Well, that's what I've got, anyway. Not much help. I'll watch here to see if anyone has ideas …