I want to use iCloud Drive to sync the Documents folder. When I run out of disk space macOS will free up space by removing old content on my SDD.
My question is, will that also remove Spotlight's knowledge (that is the meta data) of these files?
Yes Spotlight is indexing iCloud Drive. It could take a while before your iCloud Drive is indexed.
Spotlight even shows if the file you are looking for is located in iCloud Drive.
To test if the metadata is still working after the file is purged I did:
No metadata index is only searchable when iCloud documents are purged or not stored locally. A file only gets indexed when it’s written through the local filesystem and the metadata index gets updated.
Spotlight only indexes a local drive in my testing of 10.12.2 so I would expect you to lose the spotlight search data for any files that initially are downloaded to your Mac but then get purged in a low disk space pruning of the local cache of files.
There are mechanisms for macOS to maintain a spotlight index from a remote network volume and it also is conceivable Apple could engineer a solution where the spotlight metadata is kept locally when the prune occurs. I just can't verify that the implementation is performed or complete.
If I am able to get a test case, I will edit this answer with details but the work to set that up for me are more hassle than my curiosity at the moment. It would be fairly easy to set this up if you bumped your storage to 50 GB for one month and installed macOS with a boot drive less than 50 GB.