Builds an inverted index