This error occurs when a NOT condition in your query isn’t properly enclosed in parentheses. Simply adding the field directly (like Title) without parentheses will not work. To fix the issue, enclose the NOT condition in parentheses. 

Working Example:

ContentDocumentId IN (SELECT Id FROM ContentDocument WHERE NOT (Title LIKE '%Comm %' OR Title LIKE '%Eng%'))


Note: If you want to exclude Attachments specifically, set ID = Null In the first search box when running the query.