only call terms lookup once and not per segment