From bdc8c5a29d4c9fa2387933528d52c280a5dd0880 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Wed, 22 Aug 2012 19:36:31 +0200 Subject: [PATCH] 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) {