public function addDocuments($documents, $indexName = '', $indexType = '')
    {
        if ("" === $indexName && isset($documents[0])) {
            $indexName = $documents[0]->getIndexName();
        } else {
            $indexName = $this->indexNamePrefix . $indexName;
        }

        $this->mapProviders(function (SearchProviderInterface $provider) use ($documents, $indexName, $indexType) {

            $documents = array_map(function (DocumentReference $document) use ($provider) {
                return $provider->createDocument(
                    $document->getDocument(),
                    $document->getUid(),
                    $document->getIndexName(),
                    $document->getIndexType()
                );
            }, $documents);

            $provider->addDocuments($documents, $indexName, $indexType);
        });
    }
public function addDocuments($documents, $indexName = '', $indexType = '')
    {
        if ("" === $indexName && isset($documents[0])) {
            $indexName = $documents[0]->getIndexName();
        } else {
            $indexName = $this->indexNamePrefix . $indexName;
        }

        $this->mapProviders(function (SearchProviderInterface $provider) use ($documents, $indexName, $indexType) {

            $documents = array_map(function (DocumentReference $document) use ($provider) {
                return $provider->createDocument(
                    $document->getDocument(),
                    $document->getUid(),
                    $document->getIndexName(),
                    $document->getIndexType()
                );
            }, $documents);

            $provider->addDocuments($documents, $indexName, $indexType);
        });
    }
public function addDocuments ( $ documents , $ indexName = '' , $ indexType = '' ) { if ( "" === $ indexName && isset ( $ documents [ 0 ] ) ) { $ indexName = $ documents [ 0 ] -> getIndexName ( ) ; } else { $ indexName = $ this -> indexNamePrefix . $ indexName ; } $ this -> mapProviders ( function ( SearchProviderInterface $ provider ) use ( $ documents , $ indexName , $ indexType ) { $ documents = array_map ( function ( DocumentReference $ document ) use ( $ provider ) { return $ provider -> createDocument ( $ document -> getDocument ( ) , $ document -> getUid ( ) , $ document -> getIndexName ( ) , $ document -> getIndexType ( ) ) ; } , $ documents ) ; $ provider -> addDocuments ( $ documents , $ indexName , $ indexType ) ; } ) ; }
Add a collection of documents at once

@param mixed $documents
@param string $indexName Name of the index
@param string $indexType Type of the index the document is located

@return mixed
Add a collection of documents at once