Skip to content

Commit

Permalink
Merge pull request #20 from delphiki/master
Browse files Browse the repository at this point in the history
Add Elasticsearch 7.x compatibility
  • Loading branch information
CheapHasz authored Feb 9, 2021
2 parents 3cf8fd6 + 453c43b commit fe3ecc3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"license": "MIT",
"require": {
"php": "^7.1",
"elasticsearch/elasticsearch": "^5.2 || ^6.0",
"elasticsearch/elasticsearch": "^5.2 || ^6.0 || ^7.0",
"ruflin/elastica": "^6.0 || ^7.0",
"symfony/http-kernel": "^4.3 || >=5.1.5",
"symfony/dependency-injection": "^4.2 || ^5.0",
Expand Down
5 changes: 2 additions & 3 deletions src/Elastica/Traits/SearchTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Elastica\Exception\ClientException;
use Elastica\Exception\Connection\HttpException;
use Elastica\Response;
use Elastica\Request;
use Elastica\ResultSet;
use Novaway\ElasticsearchBundle\Event\ExceptionEvent;
use Novaway\ElasticsearchBundle\Event\SearchQuery;
Expand All @@ -18,13 +19,12 @@
*/
trait SearchTrait
{
public function search($query = '', $options = null): ResultSet
public function search($query = '', $options = null, string $method = Request::POST): ResultSet
{
$timestamp = (string)microtime();

$this->dispatch(new SearchQuery([
'body' => $this->getQuery()->toArray() + $this->getOptions(),
'type' => $this->getTypes(),
'indices' => $this->getIndices(),
], $timestamp), SearchQuery::NAME);
try {
Expand All @@ -40,7 +40,6 @@ public function search($query = '', $options = null): ResultSet
} catch (\Exception $e) {
$this->dispatch(new ExceptionEvent([
'body' => $this->getQuery()->toArray() + $this->getOptions(),
'type' => $this->getTypes(),
'indices' => $this->getIndices(),
], $e), ExceptionEvent::NAME);
switch (true) {
Expand Down

0 comments on commit fe3ecc3

Please sign in to comment.