Skip to content

Commit 1c84132

Browse files
committed
disable _all by default, disallow configuring _all on 6.0+ indices mapping
1 parent 25cf950 commit 1c84132

File tree

4 files changed

+13
-54
lines changed

4 files changed

+13
-54
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ All notable changes to this project will be documented in this file based on the
1919
- Removed [groovy script](https://github.com/elastic/elasticsearch/pull/21607) [#1364](https://github.com/ruflin/Elastica/pull/1364)
2020
- Removed [native script](https://github.com/elastic/elasticsearch/pull/24726) [#1364](https://github.com/ruflin/Elastica/pull/1364)
2121
- Removed old / removed script language support : javascript, python, mvel [#1364](https://github.com/ruflin/Elastica/pull/1364)
22+
- Disable [_all](https://github.com/elastic/elasticsearch/pull/22144) by default, disallow configuring _all on 6.0+ indices [#1365](https://github.com/ruflin/Elastica/pull/1365)
2223

2324
### Bugfixes
2425
- Enforce [Content-Type requirement on the layer Rest](https://github.com/elastic/elasticsearch/pull/23146), a [PR on Elastica #1301](https://github.com/ruflin/Elastica/issues/1301) solved it (it has been implemented only in the HTTP Transport), but it was not implemented in the Guzzle Transport. [#1349](https://github.com/ruflin/Elastica/pull/1349)

lib/Elastica/Type/Mapping.php

-25
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ public function disableSource($enabled = false)
145145
* _id
146146
* _type
147147
* _source
148-
* _all
149148
* _analyzer
150149
* _boost
151150
* _parent
@@ -180,30 +179,6 @@ public function getParam($key)
180179
return isset($this->_mapping[$key]) ? $this->_mapping[$key] : null;
181180
}
182181

183-
/**
184-
* Sets params for the "_all" field.
185-
*
186-
* @param array $params _all Params (enabled, store, term_vector, analyzer)
187-
*
188-
* @return $this
189-
*/
190-
public function setAllField(array $params)
191-
{
192-
return $this->setParam('_all', $params);
193-
}
194-
195-
/**
196-
* Enables the "_all" field.
197-
*
198-
* @param bool $enabled OPTIONAL (default = true)
199-
*
200-
* @return $this
201-
*/
202-
public function enableAllField($enabled = true)
203-
{
204-
return $this->setAllField(['enabled' => $enabled]);
205-
}
206-
207182
/**
208183
* Set parent type.
209184
*

test/Elastica/ResponseTest.php

+12-6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
namespace Elastica\Test;
33

44
use Elastica\Document;
5+
use Elastica\Exception\ResponseException;
56
use Elastica\Query;
67
use Elastica\Query\MatchAll;
78
use Elastica\Request;
@@ -222,14 +223,19 @@ public function testDecodeResponseWithBigIntSetToTrue()
222223
*/
223224
public function testGetDataEmpty()
224225
{
225-
$this->markTestSkipped('ES6 update: type[[non-existent-type]] missing [index: _all]');
226-
227226
$index = $this->_createIndex();
228227

229-
$response = $index->request(
230-
'non-existent-type/_mapping',
231-
Request::GET
232-
)->getData();
228+
try {
229+
$response = $index->request(
230+
'non-existent-type/_mapping',
231+
Request::GET
232+
)->getData();
233+
} catch (ResponseException $e) {
234+
$error = $e->getResponse()->getFullError();
235+
$this->assertEquals('type_missing_exception', $error['type']);
236+
$this->assertContains('non-existent-type', $error['reason']);
237+
}
238+
233239

234240
$this->assertEquals(0, count($response));
235241
}

test/Elastica/Type/MappingTest.php

-23
Original file line numberDiff line numberDiff line change
@@ -63,29 +63,6 @@ public function testMappingStoreFields()
6363
$index->delete();
6464
}
6565

66-
/**
67-
* @group functional
68-
*/
69-
public function testEnableAllField()
70-
{
71-
$this->markTestSkipped('ES6 update: [_all] is disabled in 6.0. As a replacement, you can use an [copy_to] on mapping fields to create your own catch all field.');
72-
73-
$index = $this->_createIndex();
74-
$type = $index->getType('test');
75-
76-
$mapping = new Mapping($type, []);
77-
78-
$mapping->enableAllField();
79-
80-
$data = $mapping->toArray();
81-
$this->assertTrue($data[$type->getName()]['_all']['enabled']);
82-
83-
$response = $mapping->send();
84-
$this->assertTrue($response->isOk());
85-
86-
$index->delete();
87-
}
88-
8966
/**
9067
* @group functional
9168
*/

0 commit comments

Comments
 (0)