diff --git a/README.md b/README.md index bfd05001d..cf29d980e 100644 --- a/README.md +++ b/README.md @@ -29,13 +29,15 @@ Version Matrix | Elasticsearch Version | Elasticsearch-PHP Branch | | --------------------- | ------------------------ | -| >= 6.0, < 7.0 | 6.0 | +| >= 6.6, < 7.0 | 6.7.x | +| >= 6.0, < 6.6 | 6.5.x | | >= 5.0, < 6.0 | 5.0 | | >= 2.0, < 5.0 | 1.0 or 2.0 | | >= 1.0, < 2.0 | 1.0 or 2.0 | | <= 0.90.x | 0.4 | - - If you are using Elasticsearch 6.x, use Elasticsearch-PHP 6.0 branch. + - If you are using Elasticsearch 6.6 to 6.7, use Elasticsearch-PHP 6.7.x branch. + - If you are using Elasticsearch 6.0 to 6.5, use Elasticsearch-PHP 6.5.x branch. - If you are using Elasticsearch 5.x, use Elasticsearch-PHP 5.0 branch. - If you are using Elasticsearch 1.x or 2.x, prefer using the Elasticsearch-PHP 2.0 branch. The 1.0 branch is compatible however. - If you are using a version older than 1.0, you must install the `0.4` Elasticsearch-PHP branch. Since ES 0.90.x and below is now EOL, the corresponding `0.4` branch will not receive any more development or bugfixes. Please upgrade. @@ -43,18 +45,18 @@ Version Matrix Documentation -------------- -[Full documentation can be found here.](https://www.elastic.co/guide/en/elasticsearch/client/php-api/6.0/index.html) Docs are stored within the repo under /docs/, so if you see a typo or problem, please submit a PR to fix it! +[Full documentation can be found here.](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/index.html) Docs are stored within the repo under /docs/, so if you see a typo or problem, please submit a PR to fix it! Installation via Composer ------------------------- The recommended method to install _Elasticsearch-PHP_ is through [Composer](http://getcomposer.org). -1. Add `elasticsearch/elasticsearch` as a dependency in your project's `composer.json` file (change version to suit your version of Elasticsearch, for instance this is for ES 6.0 to 6.5): +1. Add `elasticsearch/elasticsearch` as a dependency in your project's `composer.json` file (change version to suit your version of Elasticsearch, for instance for ES 6.7): ```json { "require": { - "elasticsearch/elasticsearch": "^6.5" + "elasticsearch/elasticsearch": "^6.7" } } ``` @@ -353,7 +355,7 @@ That was just a crash-course overview of the client and its syntax. If you are You'll also notice that the client is configured in a manner that facilitates easy discovery via the IDE. All core actions are available under the `$client` object (indexing, searching, getting, etc.). Index and cluster management are located under the `$client->indices()` and `$client->cluster()` objects, respectively. -Check out the rest of the [Documentation](https://www.elastic.co/guide/en/elasticsearch/client/php-api/6.0/index.html) to see how the entire client works. +Check out the rest of the [Documentation](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/index.html) to see how the entire client works. Available Licenses diff --git a/docs/installation.asciidoc b/docs/installation.asciidoc index 650cea29b..96d9a88bb 100644 --- a/docs/installation.asciidoc +++ b/docs/installation.asciidoc @@ -27,7 +27,8 @@ The master branch will always track Elasticsearch master, but it is not recommen [width="40%",options="header",frame="topbot"] |============================ |Elasticsearch Version | Elasticsearch-PHP Branch -| >= 6.0 | `6.0` +| >= 6.6, <= 6.7 | `6.7` +| >= 6.0, <= 6.5 | `6.5` | >= 5.0, <= 6.0 | `5.0` | >= 1.0, <= 5.0 | `1.0`, `2.0` | <= 0.90.* | `0.4` @@ -41,7 +42,7 @@ The master branch will always track Elasticsearch master, but it is not recommen -------------------------- { "require": { - "elasticsearch/elasticsearch": "~6.0" + "elasticsearch/elasticsearch": "~6.7.0" } } -------------------------- diff --git a/src/Elasticsearch/Endpoints/Bulk.php b/src/Elasticsearch/Endpoints/Bulk.php index 4f32744c3..b03e4b77a 100644 --- a/src/Elasticsearch/Endpoints/Bulk.php +++ b/src/Elasticsearch/Endpoints/Bulk.php @@ -78,7 +78,8 @@ public function getParamWhitelist() '_source_includes', '_source_exclude', '_source_excludes', - 'pipeline' + 'pipeline', + 'seq_no_primary_term' ); } diff --git a/src/Elasticsearch/Endpoints/Delete.php b/src/Elasticsearch/Endpoints/Delete.php index 82af6bd8f..93df0bce5 100644 --- a/src/Elasticsearch/Endpoints/Delete.php +++ b/src/Elasticsearch/Endpoints/Delete.php @@ -64,6 +64,9 @@ public function getParamWhitelist() 'timeout', 'version', 'version_type', + 'include_type_name', + 'if_primary_term', + 'if_seq_no' ); } diff --git a/src/Elasticsearch/Endpoints/Get.php b/src/Elasticsearch/Endpoints/Get.php index 04aa4f3ad..6746da242 100644 --- a/src/Elasticsearch/Endpoints/Get.php +++ b/src/Elasticsearch/Endpoints/Get.php @@ -99,7 +99,8 @@ public function getParamWhitelist() '_source_excludes', 'version', 'version_type', - 'stored_fields' + 'stored_fields', + 'include_type_name' ); } diff --git a/src/Elasticsearch/Endpoints/Index.php b/src/Elasticsearch/Endpoints/Index.php index 7b187cfba..7d63c4595 100644 --- a/src/Elasticsearch/Endpoints/Index.php +++ b/src/Elasticsearch/Endpoints/Index.php @@ -96,7 +96,8 @@ public function getParamWhitelist() 'version_type', 'pipeline', 'if_primary_term', - 'if_seq_no' + 'if_seq_no', + 'include_type_name' ); } diff --git a/src/Elasticsearch/Endpoints/Indices/Create.php b/src/Elasticsearch/Endpoints/Indices/Create.php index 3d0a43631..21488627d 100644 --- a/src/Elasticsearch/Endpoints/Indices/Create.php +++ b/src/Elasticsearch/Endpoints/Indices/Create.php @@ -65,7 +65,8 @@ public function getParamWhitelist() 'timeout', 'master_timeout', 'update_all_types', - 'wait_for_active_shards' + 'wait_for_active_shards', + 'include_type_name' ); } diff --git a/src/Elasticsearch/Endpoints/Indices/Field/Get.php b/src/Elasticsearch/Endpoints/Indices/Field/Get.php index 5ab9bc807..3b4e748fd 100644 --- a/src/Elasticsearch/Endpoints/Indices/Field/Get.php +++ b/src/Elasticsearch/Endpoints/Indices/Field/Get.php @@ -80,7 +80,7 @@ public function getParamWhitelist() 'ignore_unavailable', 'allow_no_indices', 'expand_wildcards', - 'local', + 'local' ); } diff --git a/src/Elasticsearch/Endpoints/Indices/Get.php b/src/Elasticsearch/Endpoints/Indices/Get.php index 26db1f9c4..718edd942 100644 --- a/src/Elasticsearch/Endpoints/Indices/Get.php +++ b/src/Elasticsearch/Endpoints/Indices/Get.php @@ -67,7 +67,8 @@ public function getParamWhitelist() 'ignore_unavailable', 'allow_no_indices', 'expand_wildcards', - 'human' + 'human', + 'include_type_name' ); } diff --git a/src/Elasticsearch/Endpoints/Indices/Mapping/Get.php b/src/Elasticsearch/Endpoints/Indices/Mapping/Get.php index 0b19ff040..3a5e18044 100644 --- a/src/Elasticsearch/Endpoints/Indices/Mapping/Get.php +++ b/src/Elasticsearch/Endpoints/Indices/Mapping/Get.php @@ -48,6 +48,7 @@ public function getParamWhitelist() 'expand_wildcards', 'wildcard_expansion', 'local', + 'include_type_name' ); } diff --git a/src/Elasticsearch/Endpoints/Indices/Mapping/GetField.php b/src/Elasticsearch/Endpoints/Indices/Mapping/GetField.php index 117cc538e..1f2f327a4 100644 --- a/src/Elasticsearch/Endpoints/Indices/Mapping/GetField.php +++ b/src/Elasticsearch/Endpoints/Indices/Mapping/GetField.php @@ -67,7 +67,8 @@ public function getParamWhitelist() 'ignore_unavailable', 'allow_no_indices', 'expand_wildcards', - 'local' + 'local', + 'include_type_name' ); } diff --git a/src/Elasticsearch/Endpoints/Indices/Mapping/Put.php b/src/Elasticsearch/Endpoints/Indices/Mapping/Put.php index edad342bd..fa6a423c3 100644 --- a/src/Elasticsearch/Endpoints/Indices/Mapping/Put.php +++ b/src/Elasticsearch/Endpoints/Indices/Mapping/Put.php @@ -41,19 +41,21 @@ public function setBody($body) */ public function getURI() { - if (isset($this->type) !== true) { + $index = $this->index ?? null; + $type = $this->type ?? null; + + if (null === $index && $type === $index) { throw new Exceptions\RuntimeException( - 'type is required for Put' + 'type or index are required for Put' ); } - $index = $this->index; - $type = $this->type; - $uri = "/_mapping/$type"; - - if (isset($index) === true && isset($type) === true) { - $uri = "/$index/$type/_mapping"; - } elseif (isset($type) === true) { - $uri = "/_mapping/$type"; + $uri = ''; + if (null !== $index) { + $uri = "/$index"; + } + $uri .= '/_mapping'; + if (null !== $type) { + $uri .= "/$type"; } return $uri; @@ -71,7 +73,8 @@ public function getParamWhitelist() 'ignore_unavailable', 'allow_no_indices', 'expand_wildcards', - 'update_all_types' + 'update_all_types', + 'include_type_name' ); } diff --git a/src/Elasticsearch/Endpoints/Indices/Rollover.php b/src/Elasticsearch/Endpoints/Indices/Rollover.php index 943f88358..73d730b2e 100644 --- a/src/Elasticsearch/Endpoints/Indices/Rollover.php +++ b/src/Elasticsearch/Endpoints/Indices/Rollover.php @@ -98,6 +98,7 @@ public function getParamWhitelist() 'timeout', 'master_timeout', 'wait_for_active_shards', + 'include_type_name' ); } diff --git a/src/Elasticsearch/Endpoints/Indices/Template/Get.php b/src/Elasticsearch/Endpoints/Indices/Template/Get.php index 1ea37b9d1..5308cfc5a 100644 --- a/src/Elasticsearch/Endpoints/Indices/Template/Get.php +++ b/src/Elasticsearch/Endpoints/Indices/Template/Get.php @@ -65,7 +65,8 @@ public function getParamWhitelist() return array( 'flat_settings', 'local', - 'master_timeout' + 'master_timeout', + 'include_type_name' ); } diff --git a/src/Elasticsearch/Endpoints/Indices/Template/Put.php b/src/Elasticsearch/Endpoints/Indices/Template/Put.php index 4497f0675..59a79b61f 100644 --- a/src/Elasticsearch/Endpoints/Indices/Template/Put.php +++ b/src/Elasticsearch/Endpoints/Indices/Template/Put.php @@ -89,7 +89,8 @@ public function getParamWhitelist() 'timeout', 'master_timeout', 'flat_settings', - 'create' + 'create', + 'include_type_name' ); } diff --git a/src/Elasticsearch/Endpoints/Search.php b/src/Elasticsearch/Endpoints/Search.php index 6f469dd0f..7d86b8663 100644 --- a/src/Elasticsearch/Endpoints/Search.php +++ b/src/Elasticsearch/Endpoints/Search.php @@ -104,7 +104,8 @@ public function getParamWhitelist() 'batched_reduce_size', 'typed_keys', 'pre_filter_shard_size', - 'rest_total_hits_as_int' + 'rest_total_hits_as_int', + 'seq_no_primary_term' ); } diff --git a/src/Elasticsearch/Endpoints/Update.php b/src/Elasticsearch/Endpoints/Update.php index 7af352c0c..8550e764c 100644 --- a/src/Elasticsearch/Endpoints/Update.php +++ b/src/Elasticsearch/Endpoints/Update.php @@ -87,7 +87,10 @@ public function getParamWhitelist() 'ttl', 'version', 'version_type', - '_source' + '_source', + 'include_type_name', + 'if_primary_term', + 'if_seq_no' ); } diff --git a/tests/Elasticsearch/Tests/YamlRunnerTest.php b/tests/Elasticsearch/Tests/YamlRunnerTest.php index eacfceb38..eba12148a 100644 --- a/tests/Elasticsearch/Tests/YamlRunnerTest.php +++ b/tests/Elasticsearch/Tests/YamlRunnerTest.php @@ -68,9 +68,17 @@ class YamlRunnerTest extends \PHPUnit\Framework\TestCase private static $skippedTests = [ 'nodes.stats/30_discovery.yml#Discovery stats' => 'Failing on ES 6.1+: nodes.$master.discovery is an empty array, expected to have cluster_state_queue field in it', 'indices.stats/20_translog.yml#Translog retention' => 'Failing on ES 6.3+: Failed asserting that 495 is equal to or is less than \'$creation_size\'', - 'indices.shrink/30_copy_settings.yml#Copy settings during shrink index' => 'Failing on ES 6.4+: Failed to match in test "Copy settings during shrink index". Expected [\'4\'] does not match [false] ' + 'indices.shrink/30_copy_settings.yml#Copy settings during shrink index' => 'Failing on ES 6.4+: Failed to match in test "Copy settings during shrink index". Expected [\'4\'] does not match [false] ', ]; + private static $skippedTestsIfPhpLessThan = [ + // Failing on ES 6.7+ only with PHP 7.0: Cannot access empty property + 'indices.put_mapping/11_basic_with_types.yml#Create index with invalid mappings' => '7.1.0', + 'indices.put_mapping/10_basic.yml#Create index with invalid mappings' => '7.1.0', + 'indices.create/11_basic_with_types.yml#Create index with invalid mappings' => '7.1.0', + 'indices.create/11_basic_with_types.yml#Create index with no type mappings' => '7.1.0', + 'indices.create/10_basic.yml#Create index with invalid mappings' => '7.1.0', + ]; /** * @var array A list of skipped test with their reasons */ @@ -814,8 +822,8 @@ public function yamlProvider(): array $filter = getenv('TEST_CASE') !== false ? getenv('TEST_CASE') : null; /** - * @var SplFileInfo $file -*/ + * @var SplFileInfo $file + */ foreach ($finder as $file) { $files = array_merge($files, $this->splitDocument($file, $path, $filter)); } @@ -944,6 +952,7 @@ private function formatRegex(string $regex): string */ private function splitDocument(SplFileInfo $file, string $path, string $filter = null): array { + $fileContent = $file->getContents(); // cleanup some bad comments $fileContent = str_replace('"#', '" #', $fileContent); @@ -973,6 +982,17 @@ function ($item) { $skip = false; $documentParsed = null; foreach ($documents as $documentString) { + // Extract test name + if (preg_match('/"([^"]+)"/', $documentString, $matches)) { + $testName = $matches[1]; + // Skip YAML parsing if test is signed to be skipped and if PHP is < version specified + // To prevent YAML parse error, e.g. empty property + if (array_key_exists("$fileName#$testName", static::$skippedTestsIfPhpLessThan)) { + if (version_compare(PHP_VERSION, static::$skippedTestsIfPhpLessThan["$fileName#$testName"], '<')) { + continue; + } + } + } // TODO few bad instances of teardown, should be fixed in upstream but this is a quick fix locally $documentString = str_replace(" teardown:", "teardown:", $documentString); try {