Skip to content

Commit

Permalink
Fixed full solr indexing script
Browse files Browse the repository at this point in the history
The new Solr update required setting a timeout on the Solr object.  Also, if we set REQUEST_URI, then Graylog will tell us what script had an error (when errors occur).
  • Loading branch information
inghamn committed Jun 27, 2023
1 parent a8c7da5 commit da2a5f1
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion scripts/solr/indexSolr.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@
/**
* Clear and reindex onboard data in a Solr core
*
* @copyright 2021 City of Bloomington, Indiana
* @copyright 2021-2023 City of Bloomington, Indiana
* @license https://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE
*/
declare (strict_types=1);

use Application\Models\MeetingFilesTable;
use Web\Database;
use Web\Search\Solr;

$_SERVER['REQUEST_URI'] = __FILE__;
include '../../bootstrap.php';

$solr = new Solr($SOLR['onboard']);
$solr->setTimeout(20);
$solr->purge();
$client = $solr->getClient();
$client->getAdapter()->setTimeout(20);
Expand All @@ -21,13 +24,19 @@

$table = new MeetingFilesTable();
$files = $table->find();

$db = Database::getConnection();
$sql = $db->createStatement('update meetingFiles set indexed=CURRENT_TIMESTAMP where id=?');

$total = count($files);
$c = 0;
foreach ($files as $f) {
$c++;
echo "{$f->getFullPath()} $c/$total\n";
$data = $solr->prepareIndexFields($f);
$buffer->createDocument($data);

$sql->execute([$f->getId()]);
}
$buffer->commit();

Expand Down

0 comments on commit da2a5f1

Please sign in to comment.