Merge pull request #131 from Fran6co/fix-reset
Bugfix: missing 'parameters' is causing 'MapperParsingException' when resetting index
This commit is contained in:
commit
c0cf0b921c
|
@ -52,13 +52,13 @@ class Resetter
|
|||
{
|
||||
$indexConfig = $this->getIndexConfig($indexName);
|
||||
|
||||
if (!isset($indexConfig['config']['mappings'][$typeName])) {
|
||||
if (!isset($indexConfig['config']['mappings'][$typeName]['properties'])) {
|
||||
throw new \InvalidArgumentException(sprintf('The mapping for index "%s" and type "%s" does not exist.', $indexName, $typeName));
|
||||
}
|
||||
|
||||
$type = $indexConfig['index']->getType($typeName);
|
||||
$type->delete();
|
||||
$type->setMapping($indexConfig['config']['mappings'][$typeName]);
|
||||
$type->setMapping($indexConfig['config']['mappings'][$typeName]['properties']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -15,8 +15,8 @@ class ResetterTest extends \PHPUnit_Framework_TestCase
|
|||
'index' => $this->getMockElasticaIndex(),
|
||||
'config' => array(
|
||||
'mappings' => array(
|
||||
'a' => $this->getMockElasticaTypeMapping(),
|
||||
'b' => $this->getMockElasticaTypeMapping(),
|
||||
'a' => array('properties' => array()),
|
||||
'b' => array('properties' => array()),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -24,8 +24,8 @@ class ResetterTest extends \PHPUnit_Framework_TestCase
|
|||
'index' => $this->getMockElasticaIndex(),
|
||||
'config' => array(
|
||||
'mappings' => array(
|
||||
'a' => $this->getMockElasticaTypeMapping(),
|
||||
'b' => $this->getMockElasticaTypeMapping(),
|
||||
'a' => array('properties' => array()),
|
||||
'b' => array('properties' => array()),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -82,7 +82,7 @@ class ResetterTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
$type->expects($this->once())
|
||||
->method('setMapping')
|
||||
->with($this->indexConfigsByName['foo']['config']['mappings']['a']);
|
||||
->with($this->indexConfigsByName['foo']['config']['mappings']['a']['properties']);
|
||||
|
||||
$resetter = new Resetter($this->indexConfigsByName);
|
||||
$resetter->resetIndexType('foo', 'a');
|
||||
|
@ -125,14 +125,4 @@ class ResetterTest extends \PHPUnit_Framework_TestCase
|
|||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Elastica_Type_Mapping
|
||||
*/
|
||||
private function getMockElasticaTypeMapping()
|
||||
{
|
||||
return $this->getMockBuilder('Elastica_Type_Mapping')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue