Build the inverted index