protected function buildIndex()
{
//first pass compute frequencies and all the terms in the collection
foreach ($this->collection as $id => $document) {
$freqDist = new FreqDist($document->getDocumentData());
foreach ($freqDist->getKeyValuesByFrequency() as $term => $freq) {
if (!isset($this->index[$term])) {
$this->index[$term] = array(self::FREQ => 0, self::POSTINGS => array());
}
$this->index[$term][self::FREQ] += $freq;
$this->index[$term][self::POSTINGS][] = $id;
}
$this->metadata[$id] = $document->getMetadata();
}
}