public function exportIndex(
        Manager $manager,
        $filename,
        $types,
        $chunkSize,
        OutputInterface $output,
        $maxLinesInFile = 300000
    ) {

        $search = new Search();
        $search->addQuery(new MatchAllQuery());
        $search->setSize($chunkSize);
        $search->addSort(new FieldSort('_doc'));

        $queryParameters = [
                '_source' => true,
                'scroll' => '10m',
            ];

        $searchResults = $manager->search($types, $search->toArray(), $queryParameters);

        $results = new RawIterator(
            $searchResults,
            $manager,
            [
                'duration' => $queryParameters['scroll'],
                '_scroll_id' => $searchResults['_scroll_id'],
            ]
        );

        $progress = new ProgressBar($output, $results->count());
        $progress->setRedrawFrequency(100);
        $progress->start();

        $counter = $fileCounter = 0;
        $count = $this->getFileCount($results->count(), $maxLinesInFile, $fileCounter);

        $date = date(\DateTime::ISO8601);
        $metadata = [
            'count' => $count,
            'date' => $date,
        ];

        $filename = str_replace('.json', '', $filename);
        $writer = $this->getWriter($this->getFilePath($filename.'.json'), $metadata);

        $file = [];
        foreach ($results as $data) {
            if ($counter >= $maxLinesInFile) {
                $writer->finalize();
                $writer = null;
                $fileCounter++;
                $count = $this->getFileCount($results->count(), $maxLinesInFile, $fileCounter);
                $metadata = [
                    'count' => $count,
                    'date' => $date,
                ];
                $writer = $this->getWriter($this->getFilePath($filename."_".$fileCounter.".json"), $metadata);
                $counter = 0;
            }

            $doc = array_intersect_key($data, array_flip(['_id', '_type', '_source']));
            $writer->push($doc);
            $file[] = $doc;
            $progress->advance();
            $counter++;
        }

        $writer->finalize();
        $progress->finish();
        $output->writeln('');
    }
public function exportIndex(
        Manager $manager,
        $filename,
        $types,
        $chunkSize,
        OutputInterface $output,
        $maxLinesInFile = 300000
    ) {

        $search = new Search();
        $search->addQuery(new MatchAllQuery());
        $search->setSize($chunkSize);
        $search->addSort(new FieldSort('_doc'));

        $queryParameters = [
                '_source' => true,
                'scroll' => '10m',
            ];

        $searchResults = $manager->search($types, $search->toArray(), $queryParameters);

        $results = new RawIterator(
            $searchResults,
            $manager,
            [
                'duration' => $queryParameters['scroll'],
                '_scroll_id' => $searchResults['_scroll_id'],
            ]
        );

        $progress = new ProgressBar($output, $results->count());
        $progress->setRedrawFrequency(100);
        $progress->start();

        $counter = $fileCounter = 0;
        $count = $this->getFileCount($results->count(), $maxLinesInFile, $fileCounter);

        $date = date(\DateTime::ISO8601);
        $metadata = [
            'count' => $count,
            'date' => $date,
        ];

        $filename = str_replace('.json', '', $filename);
        $writer = $this->getWriter($this->getFilePath($filename.'.json'), $metadata);

        $file = [];
        foreach ($results as $data) {
            if ($counter >= $maxLinesInFile) {
                $writer->finalize();
                $writer = null;
                $fileCounter++;
                $count = $this->getFileCount($results->count(), $maxLinesInFile, $fileCounter);
                $metadata = [
                    'count' => $count,
                    'date' => $date,
                ];
                $writer = $this->getWriter($this->getFilePath($filename."_".$fileCounter.".json"), $metadata);
                $counter = 0;
            }

            $doc = array_intersect_key($data, array_flip(['_id', '_type', '_source']));
            $writer->push($doc);
            $file[] = $doc;
            $progress->advance();
            $counter++;
        }

        $writer->finalize();
        $progress->finish();
        $output->writeln('');
    }
public function exportIndex ( Manager $ manager , $ filename , $ types , $ chunkSize , OutputInterface $ output , $ maxLinesInFile = 300000 ) { $ search = new Search ( ) ; $ search -> addQuery ( new MatchAllQuery ( ) ) ; $ search -> setSize ( $ chunkSize ) ; $ search -> addSort ( new FieldSort ( '_doc' ) ) ; $ queryParameters = [ '_source' => true , 'scroll' => '10m' , ] ; $ searchResults = $ manager -> search ( $ types , $ search -> toArray ( ) , $ queryParameters ) ; $ results = new RawIterator ( $ searchResults , $ manager , [ 'duration' => $ queryParameters [ 'scroll' ] , '_scroll_id' => $ searchResults [ '_scroll_id' ] , ] ) ; $ progress = new ProgressBar ( $ output , $ results -> count ( ) ) ; $ progress -> setRedrawFrequency ( 100 ) ; $ progress -> start ( ) ; $ counter = $ fileCounter = 0 ; $ count = $ this -> getFileCount ( $ results -> count ( ) , $ maxLinesInFile , $ fileCounter ) ; $ date = date ( \ DateTime :: ISO8601 ) ; $ metadata = [ 'count' => $ count , 'date' => $ date , ] ; $ filename = str_replace ( '.json' , '' , $ filename ) ; $ writer = $ this -> getWriter ( $ this -> getFilePath ( $ filename . '.json' ) , $ metadata ) ; $ file = [ ] ; foreach ( $ results as $ data ) { if ( $ counter >= $ maxLinesInFile ) { $ writer -> finalize ( ) ; $ writer = null ; $ fileCounter ++ ; $ count = $ this -> getFileCount ( $ results -> count ( ) , $ maxLinesInFile , $ fileCounter ) ; $ metadata = [ 'count' => $ count , 'date' => $ date , ] ; $ writer = $ this -> getWriter ( $ this -> getFilePath ( $ filename . "_" . $ fileCounter . ".json" ) , $ metadata ) ; $ counter = 0 ; } $ doc = array_intersect_key ( $ data , array_flip ( [ '_id' , '_type' , '_source' ] ) ) ; $ writer -> push ( $ doc ) ; $ file [ ] = $ doc ; $ progress -> advance ( ) ; $ counter ++ ; } $ writer -> finalize ( ) ; $ progress -> finish ( ) ; $ output -> writeln ( '' ) ; }
Exports es index to provided file.

@param Manager         $manager
@param string          $filename
@param array           $types
@param int             $chunkSize
@param int             $maxLinesInFile
@param OutputInterface $output
Exports es index to provided file .