From 9a446f54ae5fb559cb218e828a5b590d3f41af6a Mon Sep 17 00:00:00 2001 From: Normann Lou Date: Tue, 24 Jul 2012 17:35:24 +1200 Subject: [PATCH 1/3] ENHANCEMENT: add ability to use customised or project-sepcific filse for those Solr config extras, such as a stopwords.txt, which is very likely already exists if using sphinx previously for an upgrading project --- code/solr/Solr.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/code/solr/Solr.php b/code/solr/Solr.php index dd55dd7..eef0439 100644 --- a/code/solr/Solr.php +++ b/code/solr/Solr.php @@ -76,6 +76,7 @@ class Solr { } class Solr_Configure extends BuildTask { + static $customised_conf_extra_path=null; public function run($request) { $service = Solr::service(); @@ -90,7 +91,6 @@ class Solr_Configure extends BuildTask { case 'file': $local = $index['path']; $remote = isset($index['remotepath']) ? $index['remotepath'] : $local; - foreach (Solr::get_indexes() as $index => $instance) { $confdir = "$local/$index/conf"; if (!is_dir($confdir)) mkdir($confdir, 0770, true); @@ -98,7 +98,19 @@ class Solr_Configure extends BuildTask { file_put_contents("$confdir/schema.xml", $instance->generateSchema()); foreach (glob(Director::baseFolder().'/fulltextsearch/conf/extras/*') as $file) { - if (is_file($file)) copy($file, $confdir.'/'.basename($file)); + if (is_file($file)){ + if(self::$customised_conf_extra_path) { + $filename = basename($file); + $file_customised = Director::baseFolder().'/'.self::$customised_conf_extra_path.'/'.$filename; + if(is_file($file_customised)){ + copy($file_customised, $confdir.'/'.$filename); + }else{ + copy($file, $confdir.'/'.basename($file)); + } + }else{ + copy($file, $confdir.'/'.basename($file)); + } + } } } From a50d9cf553038ed1d0d1b28d937613ff359ab7be Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Wed, 22 Aug 2012 19:36:03 +0200 Subject: [PATCH 2/3] Using passthru() in Solr task exec for better debugging --- code/solr/Solr.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/solr/Solr.php b/code/solr/Solr.php index eef0439..dd7b104 100644 --- a/code/solr/Solr.php +++ b/code/solr/Solr.php @@ -208,7 +208,7 @@ class Solr_Reindex extends BuildTask { echo "$offset.."; $cmd = "php $script dev/tasks/$self index=$index class=$class start=$offset variantstate=$statevar"; - $res = `$cmd`; + $res = passthru($cmd); if (isset($_GET['verbose'])) { echo "\n Running '$cmd'\n"; echo " ".preg_replace('/\r\n|\n/', '$0 ', $res)."\n"; From bdc8c5a29d4c9fa2387933528d52c280a5dd0880 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Wed, 22 Aug 2012 19:36:31 +0200 Subject: [PATCH 3/3] Allow limiting of classes on Solr_Reindex task --- code/solr/Solr.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/code/solr/Solr.php b/code/solr/Solr.php index dd7b104..b0b9011 100644 --- a/code/solr/Solr.php +++ b/code/solr/Solr.php @@ -182,9 +182,15 @@ class Solr_Reindex extends BuildTask { foreach (Solr::get_indexes() as $index => $instance) { echo "Rebuilding {$instance->getIndexName()}\n\n"; - Solr::service($index)->deleteByQuery('*:*'); + $classes = $instance->getClasses(); + if($request->getVar('class')) { + $limitClasses = explode(',', $request->getVar('class')); + $classes = array_intersect_key($classes, array_combine($limitClasses, $limitClasses)); + } - foreach ($instance->getClasses() as $class => $options) { + Solr::service($index)->deleteByQuery('ClassHierarchy:(' . implode(' OR ', array_keys($classes)) . ')'); + + foreach ($classes as $class => $options) { $includeSubclasses = $options['include_children']; foreach (SearchVariant::reindex_states($class, $includeSubclasses) as $state) {