/** * Indexes an array of documents. * * Documents are given as an array of the array of documents. The array of documents * holds documents for all translations of the particular entity. * * @param \eZ\Publish\SPI\Search\Document[][] $documents * * @todo $documents should be generated more on demand then this and sent to Solr in chunks before final commit */ public function bulkIndexDocuments(array $documents) { $documentMap = array(); $mainTranslationsEndpoint = $this->endpointResolver->getMainLanguagesEndpoint(); $alwaysAvailableDocuments = array(); foreach ($documents as $translationDocuments) { foreach ($translationDocuments as $document) { $documentMap[$document->languageCode][] = $document; if ($mainTranslationsEndpoint !== null && $document->isMainTranslation) { $alwaysAvailableDocuments[] = $this->getAlwaysAvailableDocument($document); } } } foreach ($documentMap as $languageCode => $translationDocuments) { $this->doBulkIndexDocuments($this->endpointRegistry->getEndpoint($this->endpointResolver->getIndexingTarget($languageCode)), $translationDocuments); } if (!empty($alwaysAvailableDocuments)) { $this->doBulkIndexDocuments($this->endpointRegistry->getEndpoint($mainTranslationsEndpoint), $alwaysAvailableDocuments); } }
public function __construct(EndpointResolver $endpointResolver) { $this->hasMainLanguagesEndpoint = $endpointResolver->getMainLanguagesEndpoint() !== null; }