259,14 → 259,20 |
return $nouvelIndex; |
} |
|
protected function insererDansAlgolia($index) { |
$tailleTranche = 30000; |
echo "++++ Insertion dans Algolia ($tailleTranche) !! ++++" . PHP_EOL; |
$tranche = array_slice($index, 0, $tailleTranche); |
//var_dump($tranche); |
//$trancheJSON = json_encode($tranche); |
$this->indexAlgolia->addObjects($tranche); |
//$this->algolia-> |
/** |
* Appelle l'API Algolia pour indexer les données présentes dans $index, par |
* tranches. |
*/ |
protected function insererDansAlgolia(&$index) { |
$tailleTranche = 5000; |
echo "++++ Insertion dans Algolia (" . count($index) . " objets) !! ++++" . PHP_EOL; |
// insertion par tranches pour éviter un timeout sur l'API Algolia |
while (count($index) > 0) { |
echo "++ insertion d'une tranche de $tailleTranche... (" . count($index) . " restant)" . PHP_EOL; |
$tranche = array_splice($index, 0, $tailleTranche); |
//var_dump($tranche); |
$this->indexAlgolia->addObjects($tranche); |
} |
} |
|
// ---------------- utilitaires -------------------------------------------- |