Rewrite dates queries to avoid max doc size