private function buildNews(SearchIndexInterface $index) { $repository = $this->get('universibo_legacy.repository.news.newsitem'); foreach ($repository->findAll() as $news) { $doc = new Document(); $doc->addField(Field::unStored('title', $news->getTitolo())); $doc->addField(Field::unStored('username', $news->getUsername())); $doc->addField(Field::unStored('content', $news->getNotizia())); $doc->addField(Field::unIndexed('dbId', $news->getIdNotizia())); $doc->addField(Field::unIndexed('type', 'news')); $index->addDocument($doc); } }