Skip to content

Commit

Permalink
disable _all by default, disallow configuring _all on 6.0+ indices ma…
Browse files Browse the repository at this point in the history
…pping
  • Loading branch information
p365labs committed Aug 31, 2017
1 parent 25cf950 commit dad978e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 54 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ All notable changes to this project will be documented in this file based on the
- Removed [groovy script](https://github.com/elastic/elasticsearch/pull/21607) [#1364](https://github.com/ruflin/Elastica/pull/1364)
- Removed [native script](https://github.com/elastic/elasticsearch/pull/24726) [#1364](https://github.com/ruflin/Elastica/pull/1364)
- Removed old / removed script language support : javascript, python, mvel [#1364](https://github.com/ruflin/Elastica/pull/1364)
- 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)

### Bugfixes
- 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)
Expand Down
25 changes: 0 additions & 25 deletions lib/Elastica/Type/Mapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ public function disableSource($enabled = false)
* _id
* _type
* _source
* _all
* _analyzer
* _boost
* _parent
Expand Down Expand Up @@ -180,30 +179,6 @@ public function getParam($key)
return isset($this->_mapping[$key]) ? $this->_mapping[$key] : null;
}

/**
* Sets params for the "_all" field.
*
* @param array $params _all Params (enabled, store, term_vector, analyzer)
*
* @return $this
*/
public function setAllField(array $params)
{
return $this->setParam('_all', $params);
}

/**
* Enables the "_all" field.
*
* @param bool $enabled OPTIONAL (default = true)
*
* @return $this
*/
public function enableAllField($enabled = true)
{
return $this->setAllField(['enabled' => $enabled]);
}

/**
* Set parent type.
*
Expand Down
18 changes: 12 additions & 6 deletions test/Elastica/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
namespace Elastica\Test;

use Elastica\Document;
use Elastica\Exception\ResponseException;
use Elastica\Query;
use Elastica\Query\MatchAll;
use Elastica\Request;
Expand Down Expand Up @@ -222,14 +223,19 @@ public function testDecodeResponseWithBigIntSetToTrue()
*/
public function testGetDataEmpty()
{
$this->markTestSkipped('ES6 update: type[[non-existent-type]] missing [index: _all]');

$index = $this->_createIndex();

$response = $index->request(
'non-existent-type/_mapping',
Request::GET
)->getData();
try {
$response = $index->request(
'non-existent-type/_mapping',
Request::GET
)->getData();
} catch (ResponseException $e) {
$error = $e->getResponse()->getFullError();
$this->assertEquals('type_missing_exception', $error['type']);
$this->assertContains('non-existent-type', $error['reason']);
}


$this->assertEquals(0, count($response));
}
Expand Down
23 changes: 0 additions & 23 deletions test/Elastica/Type/MappingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,29 +63,6 @@ public function testMappingStoreFields()
$index->delete();
}

/**
* @group functional
*/
public function testEnableAllField()
{
$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.');

$index = $this->_createIndex();
$type = $index->getType('test');

$mapping = new Mapping($type, []);

$mapping->enableAllField();

$data = $mapping->toArray();
$this->assertTrue($data[$type->getName()]['_all']['enabled']);

$response = $mapping->send();
$this->assertTrue($response->isOk());

$index->delete();
}

/**
* @group functional
*/
Expand Down

0 comments on commit dad978e

Please sign in to comment.