Apple - How does “Optimize Mac Storage” for iCloud Drive interact with Spotlight and Time Machine?
Can you still search the contents of those files in Spotlight?
Yes, for a while. Spotlight doesn't purge the files from the index (
./Spotlight-V100), however it doesn't particularly ensure they remain.
Therefore, when macOS stores a file in iCloud and removes it from your home folder, the Spotlight index retains an index of the contents, but doesn't actively refresh the index. For example, resetting your Spotlight index will remove the file contents from the index. To add the files back, download them from iCloud, at which point Spotlight will index them once again.
What happens to those files in Time Machine backups?
Time Machine does not back up files in iCloud. They are ‘presumed safe’ in the cloud. They will remain on any older backups, but new incremental backups will observe the files as having been deleted.
If you restore a Time Machine backup on to a new Mac, you will log in to iCloud as part of the Setup Assistant, at which point the files will be accessible once again as normal.
Also, what happens if you edit those files on an iPad? Will the files be automatically downloaded again to the Mac?
Optimize Mac Storage attempts to keep your recent files available on your Mac. Therefore, when a file is edited by any device, your Mac will download the file locally, in case you want to continue editing there.
If not, can you search the new contents of those files in Spotlight?
Since the files are downloaded on editing, the new contents will be made available in the Spotlight index when the index is updated.
Will new Time Machine backups have a local copy with the new contents, the old contents or no local copy at all?
If a backup takes place whilst the file is downloaded, the new contents will be backed up. If the file is only in the cloud when Time Machine performs a backup, the file will not be backed up.