This is still not equivalent!

The ~.name sub-query is executable even if Solr is not available, i.e. it can be True. And since this is an OR, the whole query would become True for all records which match it, so can not assume False for the whole query.

And whether you can assume False for the ~.document.file sub-query is yet another question. In principle, you don't know - i.e. if Solr is not available, then there is no equivalent query and hence the transformation should give None and not False. That again would be True for all records (i.e. all records match no query).