/** * Being that this is a quick dirty way and should not be used in production * This is not a function available in the solr class */ protected function _index() { $rows = $this->solr->driver->get_all(); $client = Solr::getClient(null, $this->solr->config->index_name()); $client->ping(); $i = 1; foreach ($rows as $row) { $doc = $this->solr->create_model_document($row); $client->addDocument($doc); // todo remove this if ($i++ == 50) { break; } } $client->commit(); $client->optimize(); }
/** * @throws SolrClientException */ public function remove_all($optimize = true) { $client = Solr::getClient(null, $this->config->index_name()); $client->ping(); $resp = $client->deleteByQuery('*:*'); $client->commit(); if ($optimize) { $client->optimize(); } }