Skip to content
Snippets Groups Projects
Commit 9d6b0f0f authored by Demian Katz's avatar Demian Katz
Browse files

Added Solr commit utility.

- Resolves VUFIND-1101.
parent b802dec4
Branches
Tags
No related merge requests found
......@@ -234,12 +234,34 @@ class UtilController extends AbstractBase
return $updates;
}
/**
* Commit the Solr index.
*
* @return \Zend\Console\Response
*/
public function commitAction()
{
return $this->performCommit();
}
/**
* Optimize the Solr index.
*
* @return \Zend\Console\Response
*/
public function optimizeAction()
{
return $this->performCommit(true);
}
/**
* Commit (and possibly optimize) the Solr index.
*
* @param bool $optimize Should we optimize?
*
* @return \Zend\Console\Response
*/
protected function performCommit($optimize = false)
{
ini_set('memory_limit', '50M');
ini_set('max_execution_time', '3600');
......@@ -252,7 +274,9 @@ class UtilController extends AbstractBase
// Commit and Optimize the Solr Index
$solr = $this->getServiceLocator()->get('VuFind\Solr\Writer');
$solr->commit($core);
$solr->optimize($core);
if ($optimize) {
$solr->optimize($core);
}
return $this->getSuccessResponse();
}
......
<?php
/**
* Command-line tool to commit the Solr index.
*
* PHP version 5
*
* Copyright (C) Villanova University 2009.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @category VuFind2
* @package Utilities
* @author Demian Katz <demian.katz@villanova.edu>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org/wiki/performance#index_optimization Wiki
*/
// Load the Zend framework -- this will automatically trigger the appropriate
// controller action based on directory and file names
define('CLI_DIR', __DIR__); // save directory name of current script
require_once __DIR__ . '/../public/index.php';
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment