Generate logical OR instead of OrSubQueries

Instead of UNIONing 'Or' conditions, use a logical OR.

Added some more unit tests, but it is possible there is an edge case that
removing the UNION'ed sub-queries was intended to fix. Or it could be that edge
case has been fixed elsewhere (Subjects?) meaning we don't need the sub-queries
anymore.
Merge branch 'search_optimise'