fix ordering and word count when querying terms.