Collect and store document word counts in database