Functions to build and query the word count index.