Improved where clause when matching whole documents