Skip to content

Commit a4bc4e9

Browse files
committed
Remove automatic addition of store:true in mappings
1 parent fd2df90 commit a4bc4e9

File tree

3 files changed

+50
-3
lines changed

3 files changed

+50
-3
lines changed

CHANGELOG-3.1.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ https://github.com/FriendsOfSymfony/FOSElasticaBundle/commit/XXX where XXX is
99
the commit hash. To get the diff between two versions, go to
1010
https://github.com/FriendsOfSymfony/FOSElasticaBundle/compare/v3.0.4...v3.1.0
1111

12+
* 3.1.8 (Unreleased)
13+
* Removes store:true from mappings unless specifically defined
14+
1215
* 3.1.7 (2015-12-08)
1316
* Allow Elastica 2.3
1417

Index/MappingBuilder.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,6 @@ private function fixProperties(&$properties)
126126
if (in_array($property['type'], $this->skipTypes)) {
127127
continue;
128128
}
129-
if (!isset($property['store'])) {
130-
$property['store'] = true;
131-
}
132129
}
133130
}
134131
}

Tests/Index/MappingBuilderTest.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
namespace FOS\ElasticaBundle\Tests\Index;
4+
5+
use FOS\ElasticaBundle\Configuration\TypeConfig;
6+
use FOS\ElasticaBundle\Index\MappingBuilder;
7+
8+
class MappingBuilderTest extends \PHPUnit_Framework_TestCase
9+
{
10+
/**
11+
* @var MappingBuilder
12+
*/
13+
private $builder;
14+
15+
protected function setUp()
16+
{
17+
$this->builder = new MappingBuilder();
18+
}
19+
20+
public function testMappingBuilderStoreProperty()
21+
{
22+
$typeConfig = new TypeConfig('typename', [
23+
'properties' => [
24+
'storeless' => [
25+
'type' => 'string'
26+
],
27+
'stored' => [
28+
'type' => 'string',
29+
'store' => true
30+
],
31+
'unstored' => [
32+
'type' => 'string',
33+
'store' => false
34+
],
35+
]
36+
]);
37+
38+
$mapping = $this->builder->buildTypeMapping($typeConfig);
39+
40+
$this->assertArrayNotHasKey('store', $mapping['properties']['storeless']);
41+
$this->assertArrayHasKey('store', $mapping['properties']['stored']);
42+
$this->assertTrue($mapping['properties']['stored']['store']);
43+
$this->assertArrayHasKey('store', $mapping['properties']['unstored']);
44+
$this->assertFalse($mapping['properties']['unstored']['store']);
45+
}
46+
47+
}

0 commit comments

Comments
 (0)