Merge pull request #109 from dhensby/pulls/fix-aliased-index
FIX Indexes with custom index names that dont match the classname wer…
This commit is contained in:
commit
aa77e2b63a
|
@ -107,8 +107,8 @@ class Solr
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a SolrService
|
* Get a SolrService
|
||||||
*
|
*
|
||||||
* @param string $core Optional core name
|
* @param string $core Optional name of index class
|
||||||
* @return SolrService_Core
|
* @return SolrService_Core
|
||||||
*/
|
*/
|
||||||
public static function service($core = null)
|
public static function service($core = null)
|
||||||
|
@ -354,11 +354,32 @@ class Solr_Reindex extends Solr_BuildTask
|
||||||
{
|
{
|
||||||
$class = $request->getVar('class');
|
$class = $request->getVar('class');
|
||||||
|
|
||||||
|
$index = $request->getVar('index');
|
||||||
|
|
||||||
|
//find the index classname by IndexName
|
||||||
|
// this is for when index names do not match the class name (this can be done by overloading getIndexName() on
|
||||||
|
// indexes
|
||||||
|
if ($index && !ClassInfo::exists($index)) {
|
||||||
|
foreach(ClassInfo::subclassesFor('SolrIndex') as $solrIndexClass) {
|
||||||
|
$reflection = new ReflectionClass($solrIndexClass);
|
||||||
|
//skip over abstract classes
|
||||||
|
if (!$reflection->isInstantiable()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//check the indexname matches the index passed to the request
|
||||||
|
if (!strcasecmp(singleton($solrIndexClass)->getIndexName(), $index)) {
|
||||||
|
//if we match, set the correct index name and move on
|
||||||
|
$index = $solrIndexClass;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Deprecated reindex mechanism
|
// Deprecated reindex mechanism
|
||||||
$start = $request->getVar('start');
|
$start = $request->getVar('start');
|
||||||
if ($start !== null) {
|
if ($start !== null) {
|
||||||
// Run single batch directly
|
// Run single batch directly
|
||||||
$indexInstance = singleton($request->getVar('index'));
|
$indexInstance = singleton($index);
|
||||||
$state = json_decode($request->getVar('variantstate'), true);
|
$state = json_decode($request->getVar('variantstate'), true);
|
||||||
$this->runFrom($indexInstance, $class, $start, $state);
|
$this->runFrom($indexInstance, $class, $start, $state);
|
||||||
return;
|
return;
|
||||||
|
@ -372,7 +393,7 @@ class Solr_Reindex extends Solr_BuildTask
|
||||||
if ($groups) {
|
if ($groups) {
|
||||||
// Run grouped batches (id % groups = group)
|
// Run grouped batches (id % groups = group)
|
||||||
$group = $request->getVar('group');
|
$group = $request->getVar('group');
|
||||||
$indexInstance = singleton($request->getVar('index'));
|
$indexInstance = singleton($index);
|
||||||
$state = json_decode($request->getVar('variantstate'), true);
|
$state = json_decode($request->getVar('variantstate'), true);
|
||||||
|
|
||||||
$handler->runGroup($this->getLogger(), $indexInstance, $state, $class, $groups, $group);
|
$handler->runGroup($this->getLogger(), $indexInstance, $state, $class, $groups, $group);
|
||||||
|
|
|
@ -66,7 +66,7 @@ class SolrReindexImmediateHandler extends SolrReindexBase
|
||||||
|
|
||||||
// If we're in dev mode, commit more often for fun and profit
|
// If we're in dev mode, commit more often for fun and profit
|
||||||
if (Director::isDev()) {
|
if (Director::isDev()) {
|
||||||
Solr::service($indexName)->commit();
|
Solr::service(get_class($indexInstance))->commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
// This will slow down things a tiny bit, but it is done so that we don't timeout to the database during a reindex
|
// This will slow down things a tiny bit, but it is done so that we don't timeout to the database during a reindex
|
||||||
|
|
Loading…
Reference in New Issue