diff --git a/src/Elasticsearch/Endpoints/Cluster/AllocationExplain.php b/src/Elasticsearch/Endpoints/Cluster/AllocationExplain.php index 25014bf02..d38cecd40 100644 --- a/src/Elasticsearch/Endpoints/Cluster/AllocationExplain.php +++ b/src/Elasticsearch/Endpoints/Cluster/AllocationExplain.php @@ -57,6 +57,6 @@ public function getParamWhitelist() */ public function getMethod() { - return 'GET'; + return isset($this->body) ? 'POST' : 'GET'; } } diff --git a/src/Elasticsearch/Endpoints/Count.php b/src/Elasticsearch/Endpoints/Count.php index 67db3f199..dd5d24ced 100644 --- a/src/Elasticsearch/Endpoints/Count.php +++ b/src/Elasticsearch/Endpoints/Count.php @@ -82,6 +82,6 @@ public function getParamWhitelist() */ public function getMethod() { - return 'GET'; + return isset($this->body) ? 'POST' : 'GET'; } } diff --git a/src/Elasticsearch/Endpoints/CountPercolate.php b/src/Elasticsearch/Endpoints/CountPercolate.php index f87d6b5e5..f78b7870d 100644 --- a/src/Elasticsearch/Endpoints/CountPercolate.php +++ b/src/Elasticsearch/Endpoints/CountPercolate.php @@ -85,6 +85,6 @@ public function getParamWhitelist() */ public function getMethod() { - return 'GET'; + return isset($this->body) ? 'POST' : 'GET'; } } diff --git a/src/Elasticsearch/Endpoints/Explain.php b/src/Elasticsearch/Endpoints/Explain.php index 0858f8866..f359de889 100644 --- a/src/Elasticsearch/Endpoints/Explain.php +++ b/src/Elasticsearch/Endpoints/Explain.php @@ -95,6 +95,6 @@ public function getParamWhitelist() */ public function getMethod() { - return 'GET'; + return isset($this->body) ? 'POST' : 'GET'; } } diff --git a/src/Elasticsearch/Endpoints/FieldCaps.php b/src/Elasticsearch/Endpoints/FieldCaps.php index 33e53bc24..494a0297a 100644 --- a/src/Elasticsearch/Endpoints/FieldCaps.php +++ b/src/Elasticsearch/Endpoints/FieldCaps.php @@ -64,6 +64,6 @@ public function getParamWhitelist() */ public function getMethod() { - return 'GET'; + return isset($this->body) ? 'POST' : 'GET'; } } diff --git a/src/Elasticsearch/Endpoints/FieldStats.php b/src/Elasticsearch/Endpoints/FieldStats.php index 1ca80d83e..a91d43c77 100644 --- a/src/Elasticsearch/Endpoints/FieldStats.php +++ b/src/Elasticsearch/Endpoints/FieldStats.php @@ -68,6 +68,6 @@ public function getParamWhitelist() */ public function getMethod() { - return 'GET'; + return isset($this->body) ? 'POST' : 'GET'; } } diff --git a/src/Elasticsearch/Endpoints/Indices/Analyze.php b/src/Elasticsearch/Endpoints/Indices/Analyze.php index ac7787948..736464607 100644 --- a/src/Elasticsearch/Endpoints/Indices/Analyze.php +++ b/src/Elasticsearch/Endpoints/Indices/Analyze.php @@ -74,6 +74,6 @@ public function getParamWhitelist() */ public function getMethod() { - return 'GET'; + return isset($this->body) ? 'POST' : 'GET'; } } diff --git a/src/Elasticsearch/Endpoints/Indices/ValidateQuery.php b/src/Elasticsearch/Endpoints/Indices/ValidateQuery.php index df94c02a9..c17ec235b 100644 --- a/src/Elasticsearch/Endpoints/Indices/ValidateQuery.php +++ b/src/Elasticsearch/Endpoints/Indices/ValidateQuery.php @@ -72,6 +72,6 @@ public function getParamWhitelist() */ public function getMethod() { - return 'GET'; + return isset($this->body) ? 'POST' : 'GET'; } } diff --git a/src/Elasticsearch/Endpoints/Ingest/Simulate.php b/src/Elasticsearch/Endpoints/Ingest/Simulate.php index f4570bbdf..6c5459d3a 100644 --- a/src/Elasticsearch/Endpoints/Ingest/Simulate.php +++ b/src/Elasticsearch/Endpoints/Ingest/Simulate.php @@ -60,6 +60,6 @@ public function getParamWhitelist() */ public function getMethod() { - return 'GET'; + return isset($this->body) ? 'POST' : 'GET'; } } diff --git a/src/Elasticsearch/Endpoints/MTermVectors.php b/src/Elasticsearch/Endpoints/MTermVectors.php index e723920d9..5cc87c49d 100644 --- a/src/Elasticsearch/Endpoints/MTermVectors.php +++ b/src/Elasticsearch/Endpoints/MTermVectors.php @@ -65,6 +65,6 @@ public function getParamWhitelist() */ public function getMethod() { - return 'POST'; + return isset($this->body) ? 'POST' : 'GET'; } } diff --git a/src/Elasticsearch/Endpoints/Mget.php b/src/Elasticsearch/Endpoints/Mget.php index 2d7dd562c..367dcb9bb 100644 --- a/src/Elasticsearch/Endpoints/Mget.php +++ b/src/Elasticsearch/Endpoints/Mget.php @@ -88,6 +88,6 @@ public function getBody() */ public function getMethod() { - return 'POST'; + return isset($this->body) ? 'POST' : 'GET'; } } diff --git a/src/Elasticsearch/Endpoints/Msearch.php b/src/Elasticsearch/Endpoints/Msearch.php index 13e515f0a..4e9c539d2 100644 --- a/src/Elasticsearch/Endpoints/Msearch.php +++ b/src/Elasticsearch/Endpoints/Msearch.php @@ -99,6 +99,6 @@ public function getBody() */ public function getMethod() { - return 'GET'; + return 'POST'; } } diff --git a/src/Elasticsearch/Endpoints/MsearchTemplate.php b/src/Elasticsearch/Endpoints/MsearchTemplate.php index 43171741b..d0e07050a 100644 --- a/src/Elasticsearch/Endpoints/MsearchTemplate.php +++ b/src/Elasticsearch/Endpoints/MsearchTemplate.php @@ -100,6 +100,6 @@ public function getBody() */ public function getMethod() { - return 'GET'; + return 'POST'; } } diff --git a/src/Elasticsearch/Endpoints/Percolate.php b/src/Elasticsearch/Endpoints/Percolate.php index 4418d7dc4..634f00a51 100644 --- a/src/Elasticsearch/Endpoints/Percolate.php +++ b/src/Elasticsearch/Endpoints/Percolate.php @@ -93,6 +93,6 @@ public function getBody() */ public function getMethod() { - return 'GET'; + return isset($this->body) ? 'POST' : 'GET'; } } diff --git a/src/Elasticsearch/Endpoints/RenderSearchTemplate.php b/src/Elasticsearch/Endpoints/RenderSearchTemplate.php index c31eb7238..f69bddc6f 100644 --- a/src/Elasticsearch/Endpoints/RenderSearchTemplate.php +++ b/src/Elasticsearch/Endpoints/RenderSearchTemplate.php @@ -72,6 +72,6 @@ public function getBody() */ public function getMethod() { - return 'GET'; + return isset($this->body) ? 'POST' : 'GET'; } } diff --git a/src/Elasticsearch/Endpoints/Scroll.php b/src/Elasticsearch/Endpoints/Scroll.php index eb46fe31e..9c62da2cb 100644 --- a/src/Elasticsearch/Endpoints/Scroll.php +++ b/src/Elasticsearch/Endpoints/Scroll.php @@ -97,6 +97,6 @@ public function getParamWhitelist() */ public function getMethod() { - return 'GET'; + return isset($this->body) ? 'POST' : 'GET'; } } diff --git a/src/Elasticsearch/Endpoints/Search.php b/src/Elasticsearch/Endpoints/Search.php index 624bd7e76..57a539671 100644 --- a/src/Elasticsearch/Endpoints/Search.php +++ b/src/Elasticsearch/Endpoints/Search.php @@ -107,6 +107,6 @@ public function getParamWhitelist() */ public function getMethod() { - return 'GET'; + return isset($this->body) ? 'POST' : 'GET'; } } diff --git a/src/Elasticsearch/Endpoints/SearchTemplate.php b/src/Elasticsearch/Endpoints/SearchTemplate.php index 7b5c83048..978caf743 100644 --- a/src/Elasticsearch/Endpoints/SearchTemplate.php +++ b/src/Elasticsearch/Endpoints/SearchTemplate.php @@ -74,6 +74,6 @@ public function getParamWhitelist() */ public function getMethod() { - return 'GET'; + return isset($this->body) ? 'POST' : 'GET'; } } diff --git a/src/Elasticsearch/Endpoints/TermVectors.php b/src/Elasticsearch/Endpoints/TermVectors.php index 199491d1a..cc5e99c74 100644 --- a/src/Elasticsearch/Endpoints/TermVectors.php +++ b/src/Elasticsearch/Endpoints/TermVectors.php @@ -90,6 +90,6 @@ public function getParamWhitelist() */ public function getMethod() { - return 'POST'; + return isset($this->body) ? 'POST' : 'GET'; } } diff --git a/tests/Elasticsearch/Tests/Connections/ConnectionTest.php b/tests/Elasticsearch/Tests/Connections/ConnectionTest.php index 671517858..61e37f6ff 100644 --- a/tests/Elasticsearch/Tests/Connections/ConnectionTest.php +++ b/tests/Elasticsearch/Tests/Connections/ConnectionTest.php @@ -5,6 +5,7 @@ use Elasticsearch\ClientBuilder; use Elasticsearch\Connections\Connection; use Elasticsearch\Serializers\SerializerInterface; +use Elasticsearch\Serializers\SmartSerializer; use Psr\Log\LoggerInterface; class ConnectionTest extends \PHPUnit\Framework\TestCase @@ -38,7 +39,7 @@ function(){}, $this->assertInstanceOf(Connection::class, $connection); } - + public function testGetHeadersContainUserAgent() { $params = []; diff --git a/tests/Elasticsearch/Tests/Endpoints/StatusEndpointTest.php b/tests/Elasticsearch/Tests/Endpoints/StatusEndpointTest.php index b087834c1..c1896e578 100644 --- a/tests/Elasticsearch/Tests/Endpoints/StatusEndpointTest.php +++ b/tests/Elasticsearch/Tests/Endpoints/StatusEndpointTest.php @@ -1,7 +1,4 @@