diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a621f5ac6..da4af9912b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,11 @@ All notable changes to this project will be documented in this file based on the - In QueryString is not allowed to use fields parameters in conjunction with default_field parameter. This is not well documented, it's possibile to understand from [Elasticsearch tests : QueryStringQueryBuilderTests.java](https://github.com/elastic/elasticsearch/blob/6.0/core/src/test/java/org/elasticsearch/index/query/QueryStringQueryBuilderTests.java#L917) [#1352](https://github.com/ruflin/Elastica/pull/1352) - Index mapping field of type [*'string'*](https://www.elastic.co/guide/en/elasticsearch/reference/5.5/string.html) has been removed from Elasticsearch 6.0 codebase [#1353](https://github.com/ruflin/Elastica/pull/1353) - The [created and found](https://github.com/elastic/elasticsearch/pull/25516) fields in index and delete responses became obsolete after the introduction of the result field in index, update and delete responses [#1354](https://github.com/ruflin/Elastica/pull/1354) - +- Removed file scripts [#24627](https://github.com/elastic/elasticsearch/pull/24627) [#1364](https://github.com/ruflin/Elastica/pull/1364) +- 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) + ### 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) - Scroll no longer does an extra iteration both on an empty result and on searches where the last page has a significantly smaller number of results than the pages before it. diff --git a/lib/Elastica/Script/AbstractScript.php b/lib/Elastica/Script/AbstractScript.php index aece42402a..9570b12548 100644 --- a/lib/Elastica/Script/AbstractScript.php +++ b/lib/Elastica/Script/AbstractScript.php @@ -17,11 +17,7 @@ */ abstract class AbstractScript extends AbstractUpdateAction { - const LANG_MVEL = 'mvel'; - const LANG_JS = 'js'; - const LANG_GROOVY = 'groovy'; - const LANG_PYTHON = 'python'; - const LANG_NATIVE = 'native'; + const LANG_MOUSTACHE = 'moustache'; const LANG_EXPRESSION = 'expression'; const LANG_PAINLESS = 'painless'; @@ -37,7 +33,7 @@ abstract class AbstractScript extends AbstractUpdateAction * * @throws InvalidException * - * @return Script|ScriptFile|ScriptId + * @return Script|ScriptId */ public static function create($data) { @@ -75,14 +71,6 @@ private static function _createFromArray(array $data) ); } - if (isset($data['script']['file'])) { - return new ScriptFile( - $data['script']['file'], - $params, - $lang - ); - } - if (isset($data['script']['id'])) { return new ScriptId( $data['script']['id'], diff --git a/lib/Elastica/Script/ScriptFile.php b/lib/Elastica/Script/ScriptFile.php deleted file mode 100644 index 30695e5b26..0000000000 --- a/lib/Elastica/Script/ScriptFile.php +++ /dev/null @@ -1,60 +0,0 @@ - - * @author Nicolas Assing - * @author Tobias Schultze - * @author Martin Janser - * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html - */ -class ScriptFile extends AbstractScript -{ - /** - * @var string - */ - private $_scriptFile; - - /** - * @param string $scriptFile Script file name - * @param array|null $params - * @param string|null $documentId Document ID the script action should be performed on (only relevant in update context) - */ - public function __construct($scriptFile, array $params = null, $documentId = null) - { - parent::__construct($params, null, $documentId); - - $this->setScriptFile($scriptFile); - } - - /** - * @param string $scriptFile - * - * @return $this - */ - public function setScriptFile($scriptFile) - { - $this->_scriptFile = $scriptFile; - - return $this; - } - - /** - * @return string - */ - public function getScriptFile() - { - return $this->_scriptFile; - } - - /** - * {@inheritdoc} - */ - protected function getScriptTypeArray() - { - return ['file' => $this->_scriptFile]; - } -} diff --git a/test/Elastica/Index/SettingsTest.php b/test/Elastica/Index/SettingsTest.php index be1177b76a..6a32a04b7d 100644 --- a/test/Elastica/Index/SettingsTest.php +++ b/test/Elastica/Index/SettingsTest.php @@ -163,6 +163,7 @@ public function testGetDefaultNumberOfShards() $client = $this->_getClient(); $index = $client->getIndex($indexName); $index->create([], true); + $index->refresh(); $settings = $index->getSettings(); diff --git a/test/Elastica/Script/ScriptFileTest.php b/test/Elastica/Script/ScriptFileTest.php deleted file mode 100644 index 06debbb3d6..0000000000 --- a/test/Elastica/Script/ScriptFileTest.php +++ /dev/null @@ -1,190 +0,0 @@ -markTestSkipped('ES6 update: [script] unknown field [file], parser not found'); - - $index = $this->_createIndex(); - $type = $index->getType('test'); - - $type->setMapping(new Mapping(null, [ - 'location' => ['type' => 'geo_point'], - ])); - - $type->addDocuments([ - new Document(1, ['location' => ['lat' => 48.8825968, 'lon' => 2.3706111]]), - new Document(2, ['location' => ['lat' => 48.9057932, 'lon' => 2.2739735]]), - ]); - - $index->refresh(); - - $scriptFile = new ScriptFile(self::SCRIPT_FILE, ['lat' => 48.858859, 'lon' => 2.3470599]); - - $query = new Query(); - $query->addScriptField('distance', $scriptFile); - - try { - $resultSet = $type->search($query); - } catch (ResponseException $e) { - if (strpos($e->getMessage(), 'Unable to find on disk script') !== false) { - $this->markTestIncomplete('calculate-distance script not installed?'); - } - - throw $e; - } - - $results = $resultSet->getResults(); - - $this->assertEquals(2, $resultSet->count()); - $this->assertEquals([3151.855706373115], $results[0]->__get('distance')); - $this->assertEquals([7469.7862256855769], $results[1]->__get('distance')); - } - - /** - * @group unit - */ - public function testConstructor() - { - $scriptFile = new ScriptFile(self::SCRIPT_FILE); - - $expected = [ - 'script' => [ - 'file' => self::SCRIPT_FILE, - ], - ]; - $this->assertEquals(self::SCRIPT_FILE, $scriptFile->getScriptFile()); - $this->assertEquals($expected, $scriptFile->toArray()); - - $params = [ - 'param1' => 'one', - 'param2' => 10, - ]; - - $scriptFile = new ScriptFile(self::SCRIPT_FILE, $params); - - $expected = [ - 'script' => [ - 'file' => self::SCRIPT_FILE, - 'params' => $params, - ], - ]; - - $this->assertEquals(self::SCRIPT_FILE, $scriptFile->getScriptFile()); - $this->assertEquals($params, $scriptFile->getParams()); - $this->assertEquals($expected, $scriptFile->toArray()); - } - - /** - * @group unit - */ - public function testCreateString() - { - $scriptFile = ScriptFile::create(self::SCRIPT_FILE); - - $this->assertInstanceOf(ScriptFile::class, $scriptFile); - - $this->assertEquals(self::SCRIPT_FILE, $scriptFile->getScriptFile()); - - $expected = [ - 'script' => [ - 'file' => self::SCRIPT_FILE, - ], - ]; - $this->assertEquals($expected, $scriptFile->toArray()); - } - - /** - * @group unit - */ - public function testCreateScriptFile() - { - $data = new ScriptFile(self::SCRIPT_FILE); - - $scriptFile = ScriptFile::create($data); - - $this->assertInstanceOf(ScriptFile::class, $scriptFile); - $this->assertSame($data, $scriptFile); - } - - /** - * @group unit - */ - public function testCreateArray() - { - $params = [ - 'param1' => 'one', - 'param2' => 1, - ]; - $array = [ - 'script' => [ - 'file' => self::SCRIPT_FILE, - 'params' => $params, - ], - ]; - - $scriptFile = ScriptFile::create($array); - - $this->assertInstanceOf(ScriptFile::class, $scriptFile); - $this->assertEquals($array, $scriptFile->toArray()); - - $this->assertEquals(self::SCRIPT_FILE, $scriptFile->getScriptFile()); - $this->assertEquals($params, $scriptFile->getParams()); - - $this->assertEquals($array, $scriptFile->toArray()); - } - - /** - * @group unit - * @dataProvider dataProviderCreateInvalid - * @expectedException \Elastica\Exception\InvalidException - */ - public function testCreateInvalid($data) - { - ScriptFile::create($data); - } - - /** - * @return array - */ - public function dataProviderCreateInvalid() - { - return [ - [ - new \stdClass(), - ], - [ - ['params' => ['param1' => 'one']], - ], - [ - ['script' => 'calculate-distance.painless', 'params' => 'param'], - ], - ]; - } - - /** - * @group unit - */ - public function testSetScriptFile() - { - $scriptFile = new ScriptFile(self::SCRIPT_FILE); - - $this->assertSame($scriptFile, $scriptFile->setScriptFile('bar')); - $this->assertEquals('bar', $scriptFile->getScriptFile()); - } -} diff --git a/test/Elastica/Script/ScriptIdTest.php b/test/Elastica/Script/ScriptIdTest.php index c18c650e48..7914c9229c 100644 --- a/test/Elastica/Script/ScriptIdTest.php +++ b/test/Elastica/Script/ScriptIdTest.php @@ -143,8 +143,8 @@ public function testSetLang() { $script = new ScriptId(self::SCRIPT_ID, [], ScriptId::LANG_PAINLESS); - $this->assertSame($script, $script->setLang(ScriptId::LANG_GROOVY)); - $this->assertEquals(ScriptId::LANG_GROOVY, $script->getLang()); + $this->assertSame($script, $script->setLang(ScriptId::LANG_PAINLESS)); + $this->assertEquals(ScriptId::LANG_PAINLESS, $script->getLang()); } /** diff --git a/test/Elastica/Script/ScriptTest.php b/test/Elastica/Script/ScriptTest.php index afaa97ed52..8294cb1aed 100644 --- a/test/Elastica/Script/ScriptTest.php +++ b/test/Elastica/Script/ScriptTest.php @@ -142,8 +142,8 @@ public function testSetLang() { $script = new Script(self::SCRIPT, [], Script::LANG_PAINLESS); - $this->assertSame($script, $script->setLang(Script::LANG_GROOVY)); - $this->assertEquals(Script::LANG_GROOVY, $script->getLang()); + $this->assertSame($script, $script->setLang(Script::LANG_PAINLESS)); + $this->assertEquals(Script::LANG_PAINLESS, $script->getLang()); } /**