Only add match_all to query when needed