From de62c4bb4cfe5e08c64e2b62cfc4d651578650d1 Mon Sep 17 00:00:00 2001 From: Sergey Shliakhov Date: Wed, 19 May 2021 13:28:53 +0200 Subject: [PATCH 1/7] Support scout 9 --- composer.json | 2 +- src/Engines/ElasticSearchEngine.php | 37 +++++++++++++++++++++++ src/ScoutElasticSearchServiceProvider.php | 3 +- 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 1eb049d5..7777e0a1 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "require": { "php": "^7.2|^7.3", "elasticsearch/elasticsearch": ">=7.2", - "laravel/scout": "^8.0 <8.6.1", + "laravel/scout": "^8.0|^9.0", "ongr/elasticsearch-dsl": "^7.0", "roave/better-reflection": "^3.3|^4.3" }, diff --git a/src/Engines/ElasticSearchEngine.php b/src/Engines/ElasticSearchEngine.php index c29936de..4e70d55b 100644 --- a/src/Engines/ElasticSearchEngine.php +++ b/src/Engines/ElasticSearchEngine.php @@ -4,6 +4,7 @@ use Elasticsearch\Common\Exceptions\ServerErrorResponseException; use Illuminate\Database\Eloquent\Collection; +use Illuminate\Support\LazyCollection; use Laravel\Scout\Builder as BaseBuilder; use Laravel\Scout\Engines\Engine; use Matchish\ScoutElasticSearch\ElasticSearch\HitsIteratorAggregate; @@ -14,6 +15,7 @@ use Matchish\ScoutElasticSearch\ElasticSearch\SearchResults; use ONGR\ElasticsearchDSL\Query\MatchAllQuery; use ONGR\ElasticsearchDSL\Search; +use Laravel\Scout\Builder; final class ElasticSearchEngine extends Engine { @@ -117,6 +119,41 @@ public function map(BaseBuilder $builder, $results, $model) return new Collection($hits); } + /** + * Map the given results to instances of the given model via a lazy collection. + * + * @param \Laravel\Scout\Builder $builder + * @param mixed $results + * @param \Illuminate\Database\Eloquent\Model $model + * @return \Illuminate\Support\LazyCollection + */ + public function lazyMap(Builder $builder, $results, $model) + { + throw new \Error('Not implemented'); + } + + /** + * Create a search index. + * + * @param string $name + * @param array $options + * @return mixed + */ + public function createIndex($name, array $options = []) { + throw new \Error('Not implemented'); + } + + /** + * Delete a search index. + * + * @param string $name + * @return mixed + */ + public function deleteIndex($name) { + throw new \Error('Not implemented'); + } + + /** * {@inheritdoc} */ diff --git a/src/ScoutElasticSearchServiceProvider.php b/src/ScoutElasticSearchServiceProvider.php index be00314b..47cbce24 100644 --- a/src/ScoutElasticSearchServiceProvider.php +++ b/src/ScoutElasticSearchServiceProvider.php @@ -28,6 +28,7 @@ public function boot(): void return new ElasticSearchEngine($elasticsearch); }); + $this->registerCommands(); } /** @@ -37,8 +38,6 @@ public function register(): void { $this->app->register(ScoutServiceProvider::class); $this->app->bind(ImportSourceFactory::class, DefaultImportSourceFactory::class); - - $this->registerCommands(); } /** From 32da6758a3872cf1c0da2fa45bf9e116890201c5 Mon Sep 17 00:00:00 2001 From: Sergey Shliakhov Date: Wed, 19 May 2021 13:30:26 +0200 Subject: [PATCH 2/7] Bump version --- CHANGELOG.md | 2 ++ composer.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2df71ae7..9049332f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/) ## [Unreleased] +## [4.0.7] - 2021-04-21 +Support Scout 9 ## [4.0.6] - 2021-04-21 ### Fixed - Hot fix for https://github.com/matchish/laravel-scout-elasticsearch/issues/160 diff --git a/composer.json b/composer.json index 7777e0a1..49156c14 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "matchish/laravel-scout-elasticsearch", "description": "Search among multiple models with ElasticSearch and Laravel Scout", - "version": "4.0.6", + "version": "4.0.7", "keywords": [ "laravel", "scout", From 214481cc43cffaccd12a2a7d3bd9f0ccf4b79008 Mon Sep 17 00:00:00 2001 From: Sergey Shlyakhov Date: Sun, 23 May 2021 08:47:51 +0000 Subject: [PATCH 3/7] Apply fixes from StyleCI --- src/Engines/ElasticSearchEngine.php | 12 ++++++------ src/Mixed.php | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Engines/ElasticSearchEngine.php b/src/Engines/ElasticSearchEngine.php index 4e70d55b..0b7a85b9 100644 --- a/src/Engines/ElasticSearchEngine.php +++ b/src/Engines/ElasticSearchEngine.php @@ -4,7 +4,7 @@ use Elasticsearch\Common\Exceptions\ServerErrorResponseException; use Illuminate\Database\Eloquent\Collection; -use Illuminate\Support\LazyCollection; +use Laravel\Scout\Builder; use Laravel\Scout\Builder as BaseBuilder; use Laravel\Scout\Engines\Engine; use Matchish\ScoutElasticSearch\ElasticSearch\HitsIteratorAggregate; @@ -15,7 +15,6 @@ use Matchish\ScoutElasticSearch\ElasticSearch\SearchResults; use ONGR\ElasticsearchDSL\Query\MatchAllQuery; use ONGR\ElasticsearchDSL\Search; -use Laravel\Scout\Builder; final class ElasticSearchEngine extends Engine { @@ -132,14 +131,15 @@ public function lazyMap(Builder $builder, $results, $model) throw new \Error('Not implemented'); } - /** + /** * Create a search index. * * @param string $name * @param array $options * @return mixed */ - public function createIndex($name, array $options = []) { + public function createIndex($name, array $options = []) + { throw new \Error('Not implemented'); } @@ -149,11 +149,11 @@ public function createIndex($name, array $options = []) { * @param string $name * @return mixed */ - public function deleteIndex($name) { + public function deleteIndex($name) + { throw new \Error('Not implemented'); } - /** * {@inheritdoc} */ diff --git a/src/Mixed.php b/src/Mixed.php index 00c0f9fa..da14bb11 100644 --- a/src/Mixed.php +++ b/src/Mixed.php @@ -17,7 +17,8 @@ final class Mixed */ public static function search($query = '', $callback = null) { - return new Builder(new class extends Model { + return new Builder(new class extends Model + { use Searchable; }, $query, $callback); } From 9f2cb8f785fb07570638499388a061f7857d2cde Mon Sep 17 00:00:00 2001 From: Sergey Shliakhov Date: Mon, 31 May 2021 17:30:03 +0200 Subject: [PATCH 4/7] Polish --- composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/composer.json b/composer.json index 49156c14..c64444cc 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,6 @@ "fzaninotto/faker": "^1.8", "orchestra/testbench": "^4.0|^5.0", "phpunit/phpunit": "^8.0|~9.4.0", - "illuminate/support": "^6.0|^7.0|^8.0", "nunomaduro/larastan": "~0.6", "laravel/legacy-factories": "^1.0" }, From 538dd1b617c71dc00bea8a9f9f3e78c5bc713a89 Mon Sep 17 00:00:00 2001 From: Sergey Shlyakhov Date: Mon, 31 May 2021 17:31:51 +0200 Subject: [PATCH 5/7] Update composer.json --- composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/composer.json b/composer.json index 49156c14..c64444cc 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,6 @@ "fzaninotto/faker": "^1.8", "orchestra/testbench": "^4.0|^5.0", "phpunit/phpunit": "^8.0|~9.4.0", - "illuminate/support": "^6.0|^7.0|^8.0", "nunomaduro/larastan": "~0.6", "laravel/legacy-factories": "^1.0" }, From e229adb5475550581c2090fd1ba6ef27630c0bcd Mon Sep 17 00:00:00 2001 From: Sergey Shliakhov Date: Fri, 4 Jun 2021 14:12:44 +0200 Subject: [PATCH 6/7] Fix dependencies --- Makefile | 2 +- composer.json | 9 ++++----- docker/app/Dockerfile | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index ebb73c81..5aee39de 100644 --- a/Makefile +++ b/Makefile @@ -34,7 +34,7 @@ shell: up ## Start shell into application container $(docker_compose_bin) exec "$(APP_CONTAINER_NAME)" /bin/sh install: up ## Install application dependencies into application container - $(docker_compose_bin) exec "$(APP_CONTAINER_NAME)" composer install --no-interaction --ansi --no-suggest + $(docker_compose_bin) exec "$(APP_CONTAINER_NAME)" composer install --no-interaction --ansi test: up ## Execute application tests $(docker_compose_bin) exec "$(APP_CONTAINER_NAME)" ./vendor/bin/phpstan analyze diff --git a/composer.json b/composer.json index c64444cc..06e72a52 100644 --- a/composer.json +++ b/composer.json @@ -19,16 +19,15 @@ "require": { "php": "^7.2|^7.3", "elasticsearch/elasticsearch": ">=7.2", - "laravel/scout": "^8.0|^9.0", + "laravel/scout": "8.0|^9.0", "ongr/elasticsearch-dsl": "^7.0", "roave/better-reflection": "^3.3|^4.3" }, "require-dev": { - "fzaninotto/faker": "^1.8", - "orchestra/testbench": "^4.0|^5.0", - "phpunit/phpunit": "^8.0|~9.4.0", + "laravel/legacy-factories": "^1.0", "nunomaduro/larastan": "~0.6", - "laravel/legacy-factories": "^1.0" + "orchestra/testbench": "^6.18", + "phpunit/phpunit": "^8.0|~9.4.0" }, "autoload-dev": { "psr-4": { diff --git a/docker/app/Dockerfile b/docker/app/Dockerfile index 77e085aa..46525d02 100644 --- a/docker/app/Dockerfile +++ b/docker/app/Dockerfile @@ -1,5 +1,5 @@ # See https://github.com/docker-library/php/blob/master/7.1/fpm/Dockerfile -FROM php:7.2-fpm as php +FROM php:7.3-fpm as php ARG TIMEZONE MAINTAINER Shliakhov Sergey From b9e09ab68bb51ee80307a1f7dd4669487d8a8211 Mon Sep 17 00:00:00 2001 From: Sergey Shlyakhov Date: Sat, 5 Jun 2021 08:19:26 +0200 Subject: [PATCH 7/7] Fix typo --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 06e72a52..8273629a 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "require": { "php": "^7.2|^7.3", "elasticsearch/elasticsearch": ">=7.2", - "laravel/scout": "8.0|^9.0", + "laravel/scout": "^8.0|^9.0", "ongr/elasticsearch-dsl": "^7.0", "roave/better-reflection": "^3.3|^4.3" },