From c118757c95466a022e460dc29a8963eb857eb629 Mon Sep 17 00:00:00 2001 From: Sergey Shlyakhov Date: Sun, 2 Jun 2019 10:00:12 +0300 Subject: [PATCH 01/39] Add to travic matrix elasticsearch 7 --- .travis.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index bc90eda5..98cd9e31 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,9 @@ php: - 7.3 - nightly +env: + - ELASTICSEARCH_VERSION=6.6.2 + - ELASTICSEARCH_VERSION=7.1.1 cache: directories: - "$HOME/.composer/cache/files" @@ -16,9 +19,10 @@ cache: matrix: allow_failures: - php: nightly + - env: ELASTICSEARCH_VERSION=7.1.1 before_script: - - curl -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.6.2.deb && sudo dpkg -i --force-confnew elasticsearch-6.6.2.deb && sudo service elasticsearch restart + - curl -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-$ELASTICSEARCH_VERSION.deb && sudo dpkg -i --force-confnew elasticsearch-$ELASTICSEARCH_VERSION.deb && sudo service elasticsearch restart - sleep 20 - curl -X GET "localhost:9200/_cluster/health?wait_for_status=yellow&timeout=50s" - travis_retry composer self-update From 86eec091f5263c6d4481634f5ab6f918391a5478 Mon Sep 17 00:00:00 2001 From: Sergey Shlyakhov Date: Sun, 2 Jun 2019 10:13:06 +0300 Subject: [PATCH 02/39] Fix travis config --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 98cd9e31..f04d8490 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,8 +10,8 @@ php: - nightly env: - - ELASTICSEARCH_VERSION=6.6.2 - - ELASTICSEARCH_VERSION=7.1.1 + - ELASTICSEARCH_BUILD=6.6.2.deb + - ELASTICSEARCH_BUILD=7.1.1-amd64.deb cache: directories: - "$HOME/.composer/cache/files" @@ -22,7 +22,7 @@ matrix: - env: ELASTICSEARCH_VERSION=7.1.1 before_script: - - curl -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-$ELASTICSEARCH_VERSION.deb && sudo dpkg -i --force-confnew elasticsearch-$ELASTICSEARCH_VERSION.deb && sudo service elasticsearch restart + - curl -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-$ELASTICSEARCH_BUILD && sudo dpkg -i --force-confnew elasticsearch-$ELASTICSEARCH_BUILD && sudo service elasticsearch restart - sleep 20 - curl -X GET "localhost:9200/_cluster/health?wait_for_status=yellow&timeout=50s" - travis_retry composer self-update From 9041d516e2239694ae28615dd186b1160b4d6aa3 Mon Sep 17 00:00:00 2001 From: Sergey Shlyakhov Date: Mon, 3 Jun 2019 16:16:10 +0300 Subject: [PATCH 03/39] Remove duplicate env section from travis config --- .travis.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index f04d8490..c0de1d57 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,17 +1,15 @@ language: php env: + - ELASTICSEARCH_BUILD=6.6.2.deb + - ELASTICSEARCH_BUILD=7.1.1-amd64.deb - ELASTICSEARCH_HOST=localhost:9200 - php: - 7.1 - 7.2 - 7.3 - nightly - -env: - - ELASTICSEARCH_BUILD=6.6.2.deb - - ELASTICSEARCH_BUILD=7.1.1-amd64.deb + cache: directories: - "$HOME/.composer/cache/files" From ae58169dbe0d40e0db6608bb22dfc9f2b792fd58 Mon Sep 17 00:00:00 2001 From: Sergey Shlyakhov Date: Tue, 4 Jun 2019 03:49:49 +0300 Subject: [PATCH 04/39] Set elasticsearch host as global env variable --- .travis.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c0de1d57..f87af285 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,12 @@ language: php +global: + - ELASTICSEARCH_HOST=localhost:9200 + env: - ELASTICSEARCH_BUILD=6.6.2.deb - ELASTICSEARCH_BUILD=7.1.1-amd64.deb - - ELASTICSEARCH_HOST=localhost:9200 + php: - 7.1 - 7.2 From 594afdf93cd73598ac1efd4a6ef7295213c1b287 Mon Sep 17 00:00:00 2001 From: Sergey Shlyakhov Date: Tue, 4 Jun 2019 03:57:12 +0300 Subject: [PATCH 05/39] Set env in one line --- .travis.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index f87af285..a953346b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,8 @@ language: php - -global: - - ELASTICSEARCH_HOST=localhost:9200 env: - - ELASTICSEARCH_BUILD=6.6.2.deb - - ELASTICSEARCH_BUILD=7.1.1-amd64.deb + - ELASTICSEARCH_BUILD=6.6.2.deb ELASTICSEARCH_HOST=localhost:9200 + - ELASTICSEARCH_BUILD=7.1.1-amd64.deb ELASTICSEARCH_HOST=localhost:9200 php: - 7.1 @@ -20,7 +17,7 @@ cache: matrix: allow_failures: - php: nightly - - env: ELASTICSEARCH_VERSION=7.1.1 + - env: ELASTICSEARCH_BUILD=7.1.1 before_script: - curl -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-$ELASTICSEARCH_BUILD && sudo dpkg -i --force-confnew elasticsearch-$ELASTICSEARCH_BUILD && sudo service elasticsearch restart From 7f8f6dd2d37cfb083824d9b94f5941c922a3cc4b Mon Sep 17 00:00:00 2001 From: Sergey Shlyakhov Date: Tue, 4 Jun 2019 04:31:01 +0300 Subject: [PATCH 06/39] Config elasticsearch --- .travis.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a953346b..11094554 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,7 +20,13 @@ matrix: - env: ELASTICSEARCH_BUILD=7.1.1 before_script: - - curl -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-$ELASTICSEARCH_BUILD && sudo dpkg -i --force-confnew elasticsearch-$ELASTICSEARCH_BUILD && sudo service elasticsearch restart + - curl -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-$ELASTICSEARCH_BUILD + - sudo dpkg -i --force-confnew elasticsearch-$ELASTICSEARCH_BUILD + - sudo sed -i.old 's/-Xms1g/-Xms128m/' /etc/elasticsearch/jvm.options + - sudo sed -i.old 's/-Xmx1g/-Xmx128m/' /etc/elasticsearch/jvm.options + - echo -e '-XX:+DisableExplicitGC\n-Djdk.io.permissionsUseCanonicalPath=true\n-Dlog4j.skipJansi=true\n-server\n' | sudo tee -a /etc/elasticsearch/jvm.options + - sudo chown -R elasticsearch:elasticsearch /etc/default/elasticsearch + - sudo service elasticsearch restart - sleep 20 - curl -X GET "localhost:9200/_cluster/health?wait_for_status=yellow&timeout=50s" - travis_retry composer self-update From 7b063d91be79baf02770563c4f0f11edafdca84b Mon Sep 17 00:00:00 2001 From: Sergey Shlyakhov Date: Tue, 4 Jun 2019 04:58:37 +0300 Subject: [PATCH 07/39] Fix total count issue. In elasticsearch 7 `hits.total` is array, so we need return hits.total.value instead hits.total --- src/Engines/ElasticSearchEngine.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Engines/ElasticSearchEngine.php b/src/Engines/ElasticSearchEngine.php index 559fe7be..b51125d9 100644 --- a/src/Engines/ElasticSearchEngine.php +++ b/src/Engines/ElasticSearchEngine.php @@ -113,7 +113,7 @@ public function map(BaseBuilder $builder, $results, $model) */ public function getTotalCount($results) { - return $results['hits']['total']; + return $results['hits']['total']['value']; } /** From e9b23b16272d4e577c0c17ed22db1d3822d7cdc6 Mon Sep 17 00:00:00 2001 From: Sergey Shlyakhov Date: Tue, 4 Jun 2019 05:03:57 +0300 Subject: [PATCH 08/39] Make mappings compatible with elasticsearch 7 --- tests/laravel/config/elasticsearch.php | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/tests/laravel/config/elasticsearch.php b/tests/laravel/config/elasticsearch.php index 8cfb8955..b414dbbc 100644 --- a/tests/laravel/config/elasticsearch.php +++ b/tests/laravel/config/elasticsearch.php @@ -4,17 +4,15 @@ 'indices' => [ 'mappings' => [ 'default' => [ - '_doc' => [ - 'properties' => [ - 'created_at' => [ - 'type' => 'date', - ], - 'updated_at' => [ - 'type' => 'date', - ], - 'deleted_at' => [ - 'type' => 'date', - ], + 'properties' => [ + 'created_at' => [ + 'type' => 'date', + ], + 'updated_at' => [ + 'type' => 'date', + ], + 'deleted_at' => [ + 'type' => 'date', ], ], ], From 36b60832dcc2c41c8fe7bfab92631a68477f8b4f Mon Sep 17 00:00:00 2001 From: Sergey Shliakhov Date: Fri, 7 Jun 2019 15:02:53 +0300 Subject: [PATCH 09/39] Migrate elasticsearch container from 6 to 7 --- docker-compose.yml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index a469effc..d77589be 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -23,16 +23,13 @@ services: networks: - default elasticsearch: - image: docker.elastic.co/elasticsearch/elasticsearch:6.6.0 + image: docker.elastic.co/elasticsearch/elasticsearch:7.1.1 user: "1000:1000" volumes: - elasticsearch-data:/usr/share/elasticsearch/data environment: - - cluster.name=docker-cluster - - cluster.routing.allocation.disk.threshold_enabled=true - - cluster.routing.allocation.disk.watermark.flood_stage=200mb - - cluster.routing.allocation.disk.watermark.low=500mb - - cluster.routing.allocation.disk.watermark.high=300mb + - discovery.type=single-node + - cluster.routing.allocation.disk.threshold_enabled=false - bootstrap.memory_lock=true - "ES_JAVA_OPTS=-Xms512m -Xmx512m" ulimits: @@ -47,7 +44,8 @@ services: image: lmenezes/cerebro ports: - "9002:9000" - + networks: + - default networks: default: driver: bridge From 99469de81127f09b6f7ee6885be35516cbc2c600 Mon Sep 17 00:00:00 2001 From: Sergey Shliakhov Date: Fri, 7 Jun 2019 15:05:33 +0300 Subject: [PATCH 10/39] Remove _doc mappings --- config/elasticsearch.php | 8 +++----- tests/TestCase.php | 16 +++++++--------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/config/elasticsearch.php b/config/elasticsearch.php index 90b8c2fc..9a4a1dd9 100644 --- a/config/elasticsearch.php +++ b/config/elasticsearch.php @@ -5,11 +5,9 @@ 'indices' => [ 'mappings' => [ 'default' => [ - '_doc' => [ - 'properties' => [ - 'id' => [ - 'type' => 'keyword', - ], + 'properties' => [ + 'id' => [ + 'type' => 'keyword', ], ], ], diff --git a/tests/TestCase.php b/tests/TestCase.php index 0e41c408..5fa9fa2e 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -44,16 +44,14 @@ protected function getEnvironmentSetUp($app) ]); $app['config']->set('elasticsearch', require(__DIR__.'/../config/elasticsearch.php')); $app['config']->set('elasticsearch.indices.mappings.products', [ - '_doc' => [ - 'properties' => [ - 'type' => [ - 'type' => 'keyword', - ], - 'price' => [ - 'type' => 'integer', - ], - ], + 'properties' => [ + 'type' => [ + 'type' => 'keyword', ], + 'price' => [ + 'type' => 'integer', + ], + ], ]); } From b5fc71a581dbab8d1097fbfbb57758a7f0b1c7a6 Mon Sep 17 00:00:00 2001 From: Sergey Shliakhov Date: Fri, 7 Jun 2019 15:07:50 +0300 Subject: [PATCH 11/39] Fix hits total. $response['hits']['total'] now is array. So we change it to $response['hits']['total']['value'] --- tests/Feature/FlushCommandTest.php | 2 +- tests/Feature/ImportCommandTest.php | 6 +++--- tests/Integration/Engines/ElasticSearchEngineTest.php | 6 +++--- tests/Integration/Jobs/Stages/PullFromSourceTest.php | 10 +++++----- tests/Integration/Jobs/Stages/RefreshIndexTest.php | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/Feature/FlushCommandTest.php b/tests/Feature/FlushCommandTest.php index 14c4c0b6..1f189c41 100644 --- a/tests/Feature/FlushCommandTest.php +++ b/tests/Feature/FlushCommandTest.php @@ -38,6 +38,6 @@ public function test_clear_index(): void ]; $response = $this->elasticsearch->search($params); - $this->assertEquals(0, $response['hits']['total']); + $this->assertEquals(0, $response['hits']['total']['value']); } } diff --git a/tests/Feature/ImportCommandTest.php b/tests/Feature/ImportCommandTest.php index bcb515b0..d0701db9 100644 --- a/tests/Feature/ImportCommandTest.php +++ b/tests/Feature/ImportCommandTest.php @@ -36,7 +36,7 @@ public function test_import_entites(): void ], ]; $response = $this->elasticsearch->search($params); - $this->assertEquals($productsAmount, $response['hits']['total']); + $this->assertEquals($productsAmount, $response['hits']['total']['value']); } public function test_import_entites_in_queue(): void @@ -62,7 +62,7 @@ public function test_import_entites_in_queue(): void ], ]; $response = $this->elasticsearch->search($params); - $this->assertEquals($productsAmount, $response['hits']['total']); + $this->assertEquals($productsAmount, $response['hits']['total']['value']); } public function test_import_all_pages(): void @@ -86,7 +86,7 @@ public function test_import_all_pages(): void ], ]; $response = $this->elasticsearch->search($params); - $this->assertEquals($productsAmount, $response['hits']['total']); + $this->assertEquals($productsAmount, $response['hits']['total']['value']); } public function test_remove_old_index_after_switching_to_new(): void diff --git a/tests/Integration/Engines/ElasticSearchEngineTest.php b/tests/Integration/Engines/ElasticSearchEngineTest.php index 7e0f4501..630d91a7 100644 --- a/tests/Integration/Engines/ElasticSearchEngineTest.php +++ b/tests/Integration/Engines/ElasticSearchEngineTest.php @@ -49,7 +49,7 @@ public function test_update() ], ]; $response = $this->elasticsearch->search($params); - $this->assertEquals($models->count(), $response['hits']['total']); + $this->assertEquals($models->count(), $response['hits']['total']['value']); foreach ($response['hits']['hits'] as $doc) { $this->assertEquals('Scout', $doc['_source']['title']); } @@ -72,7 +72,7 @@ public function test_delete() ], ]; $response = $this->elasticsearch->search($params); - $this->assertEquals(1, $response['hits']['total']); + $this->assertEquals(1, $response['hits']['total']['value']); foreach ($response['hits']['hits'] as $doc) { $this->assertEquals($shouldBeNotDeleted->getScoutKey(), $doc['_id']); } @@ -94,7 +94,7 @@ public function test_flush() ], ]; $response = $this->elasticsearch->search($params); - $this->assertEquals(0, $response['hits']['total']); + $this->assertEquals(0, $response['hits']['total']['value']); } public function test_map_with_custom_key_name() diff --git a/tests/Integration/Jobs/Stages/PullFromSourceTest.php b/tests/Integration/Jobs/Stages/PullFromSourceTest.php index f54851d6..7a637479 100644 --- a/tests/Integration/Jobs/Stages/PullFromSourceTest.php +++ b/tests/Integration/Jobs/Stages/PullFromSourceTest.php @@ -39,7 +39,7 @@ public function test_put_all_entites_to_index(): void ], ]; $response = $this->elasticsearch->search($params); - $this->assertEquals($productsAmount, $response['hits']['total']); + $this->assertEquals($productsAmount, $response['hits']['total']['value']); } public function test_dont_put_entities_if_no_entities_in_collection(): void @@ -62,7 +62,7 @@ public function test_dont_put_entities_if_no_entities_in_collection(): void ], ]; $response = $this->elasticsearch->search($params); - $this->assertEquals(0, $response['hits']['total']); + $this->assertEquals(0, $response['hits']['total']['value']); } public function test_put_all_to_index_if_amount_of_entities_more_than_chunk_size(): void @@ -94,7 +94,7 @@ public function test_put_all_to_index_if_amount_of_entities_more_than_chunk_size ], ]; $response = $this->elasticsearch->search($params); - $this->assertEquals($productsAmount, $response['hits']['total']); + $this->assertEquals($productsAmount, $response['hits']['total']['value']); } public function test_pull_soft_delete_meta_data() @@ -162,7 +162,7 @@ public function test_pull_soft_deleted() ], ]; $response = $this->elasticsearch->search($params); - $this->assertEquals(3, $response['hits']['total']); + $this->assertEquals(3, $response['hits']['total']['value']); } public function test_no_searchables_no_chunks() @@ -198,6 +198,6 @@ public function test_chunked_pull_only_one_page() ]; $response = $this->elasticsearch->search($params); - $this->assertEquals(3, $response['hits']['total']); + $this->assertEquals(3, $response['hits']['total']['value']); } } diff --git a/tests/Integration/Jobs/Stages/RefreshIndexTest.php b/tests/Integration/Jobs/Stages/RefreshIndexTest.php index 6d32c0b3..b376262f 100644 --- a/tests/Integration/Jobs/Stages/RefreshIndexTest.php +++ b/tests/Integration/Jobs/Stages/RefreshIndexTest.php @@ -41,6 +41,6 @@ public function test_refresh_index(): void ], ]; $response = $this->elasticsearch->search($params); - $this->assertEquals(1, $response['hits']['total']); + $this->assertEquals(1, $response['hits']['total']['value']); } } From 95050a5b28b0998c2e2858ad7aa6839c6bf2d953 Mon Sep 17 00:00:00 2001 From: Sergey Shliakhov Date: Fri, 7 Jun 2019 15:15:10 +0300 Subject: [PATCH 12/39] Run elasticsearch 6 from travis build matrix --- .travis.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 11094554..373d1c7e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,14 @@ language: php - + env: - - ELASTICSEARCH_BUILD=6.6.2.deb ELASTICSEARCH_HOST=localhost:9200 - ELASTICSEARCH_BUILD=7.1.1-amd64.deb ELASTICSEARCH_HOST=localhost:9200 - + php: - 7.1 - 7.2 - 7.3 - nightly - + cache: directories: - "$HOME/.composer/cache/files" @@ -20,7 +19,7 @@ matrix: - env: ELASTICSEARCH_BUILD=7.1.1 before_script: - - curl -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-$ELASTICSEARCH_BUILD + - curl -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-$ELASTICSEARCH_BUILD - sudo dpkg -i --force-confnew elasticsearch-$ELASTICSEARCH_BUILD - sudo sed -i.old 's/-Xms1g/-Xms128m/' /etc/elasticsearch/jvm.options - sudo sed -i.old 's/-Xmx1g/-Xmx128m/' /etc/elasticsearch/jvm.options From 5380a644bce3d5ab106bfbd11079033e005d34a7 Mon Sep 17 00:00:00 2001 From: Sergey Shlyakhov Date: Fri, 14 Jun 2019 04:44:39 +0300 Subject: [PATCH 13/39] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e5fd3f2f..51e5b0bc 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ ], "require": { "php": "^7.1.3", - "elasticsearch/elasticsearch": "~6.0", + "elasticsearch/elasticsearch": "~7.0", "laravel/scout": "^6.1.1|^7.0", "ongr/elasticsearch-dsl": "^6.0" }, From c531ff4d3e3dc1b296adad13c83396a5c23a5d82 Mon Sep 17 00:00:00 2001 From: Sergey Shlyakhov Date: Fri, 14 Jun 2019 05:09:17 +0300 Subject: [PATCH 14/39] Fix: Elasticsearch client search method accept only array --- tests/Unit/Engines/ElasticSearchEngineTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Unit/Engines/ElasticSearchEngineTest.php b/tests/Unit/Engines/ElasticSearchEngineTest.php index a37768fd..0e0d7058 100644 --- a/tests/Unit/Engines/ElasticSearchEngineTest.php +++ b/tests/Unit/Engines/ElasticSearchEngineTest.php @@ -36,10 +36,10 @@ public function test_pass_search_builder_to_callback() { $client = m::mock(Client::class); $engine = new ElasticSearchEngine($client); - $client->shouldReceive('search')->once()->with(m::type(Search::class)); + $client->shouldReceive('search')->once()->with(m::type('array')); $query = 'zonda'; $builder = new Builder(new Product(), $query, function ($client, $query) { - return $client->search($query); + return $client->search($query->toArray()); }); $engine->search($builder); } From 144b8fd8b7b12b5dd0ab8cdedfd278864ab69f01 Mon Sep 17 00:00:00 2001 From: Sergey Shlyakhov Date: Fri, 14 Jun 2019 05:24:30 +0300 Subject: [PATCH 15/39] Add PHPDoc comment --- src/Jobs/Stages/CleanUp.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Jobs/Stages/CleanUp.php b/src/Jobs/Stages/CleanUp.php index c3d351ed..9dd69379 100644 --- a/src/Jobs/Stages/CleanUp.php +++ b/src/Jobs/Stages/CleanUp.php @@ -33,6 +33,7 @@ public function handle(Client $elasticsearch): void $searchable = $this->searchable; $params = GetAliasParams::anyIndex($searchable->searchableAs()); try { + /** @var array $response */ $response = $elasticsearch->indices()->getAliases($params->toArray()); } catch (Missing404Exception $e) { $response = []; From 7f07efd167d0fc66fdd75a0f1c49e475680e62f4 Mon Sep 17 00:00:00 2001 From: Sergey Shlyakhov Date: Fri, 14 Jun 2019 05:25:19 +0300 Subject: [PATCH 16/39] Add PHPDoc comment --- src/Jobs/Stages/SwitchToNewAndRemoveOldIndex.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Jobs/Stages/SwitchToNewAndRemoveOldIndex.php b/src/Jobs/Stages/SwitchToNewAndRemoveOldIndex.php index 025c7242..7457b662 100644 --- a/src/Jobs/Stages/SwitchToNewAndRemoveOldIndex.php +++ b/src/Jobs/Stages/SwitchToNewAndRemoveOldIndex.php @@ -37,6 +37,7 @@ public function handle(Client $elasticsearch): void /** @var Searchable $searchable */ $searchable = $this->searchable; $params = Get::anyIndex($searchable->searchableAs()); + /** @var array $response */ $response = $elasticsearch->indices()->getAliases($params->toArray()); $params = new Update(); From a219af39f48a15f9287bbb3436e4c4d691dc42c5 Mon Sep 17 00:00:00 2001 From: Sergey Shlyakhov Date: Sat, 24 Aug 2019 12:50:23 +0300 Subject: [PATCH 17/39] Constrain elasticsearch/elasticsearch elasticsearch/elasticsearch should be less then 7.2 https://github.com/matchish/laravel-scout-elasticsearch/issues/40 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 51e5b0bc..ceae1bec 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ ], "require": { "php": "^7.1.3", - "elasticsearch/elasticsearch": "~7.0", + "elasticsearch/elasticsearch": ">=7.0 <7.2", "laravel/scout": "^6.1.1|^7.0", "ongr/elasticsearch-dsl": "^6.0" }, From 1e70a33b7da58a29809e7699ee8262670afcce32 Mon Sep 17 00:00:00 2001 From: Sergey Shlyakhov Date: Sat, 24 Aug 2019 10:02:57 +0000 Subject: [PATCH 18/39] Apply fixes from StyleCI --- src/Engines/ElasticSearchEngine.php | 1 - tests/Unit/Engines/ElasticSearchEngineTest.php | 1 - 2 files changed, 2 deletions(-) diff --git a/src/Engines/ElasticSearchEngine.php b/src/Engines/ElasticSearchEngine.php index b51125d9..2edfb3f9 100644 --- a/src/Engines/ElasticSearchEngine.php +++ b/src/Engines/ElasticSearchEngine.php @@ -8,7 +8,6 @@ use Laravel\Scout\Builder as BaseBuilder; use Illuminate\Database\Eloquent\Collection; use ONGR\ElasticsearchDSL\Query\MatchAllQuery; -use Matchish\ScoutElasticSearch\ElasticSearch\Index; use Matchish\ScoutElasticSearch\ElasticSearch\Params\Bulk; use Matchish\ScoutElasticSearch\ElasticSearch\SearchFactory; use Matchish\ScoutElasticSearch\ElasticSearch\SearchResults; diff --git a/tests/Unit/Engines/ElasticSearchEngineTest.php b/tests/Unit/Engines/ElasticSearchEngineTest.php index 0e0d7058..4b92032b 100644 --- a/tests/Unit/Engines/ElasticSearchEngineTest.php +++ b/tests/Unit/Engines/ElasticSearchEngineTest.php @@ -7,7 +7,6 @@ use Tests\TestCase; use Elasticsearch\Client; use Laravel\Scout\Builder; -use ONGR\ElasticsearchDSL\Search; use Matchish\ScoutElasticSearch\Engines\ElasticSearchEngine; class ElasticSearchEngineTest extends TestCase From 27a0b921f8e095e4d557ccc9d8a645c9aca68980 Mon Sep 17 00:00:00 2001 From: mackhankins Date: Mon, 26 Aug 2019 13:49:10 -0500 Subject: [PATCH 19/39] Use getAlias instead of getAliases --- CHANGELOG.md | 4 ++++ composer.json | 4 ++-- src/Jobs/Stages/CleanUp.php | 2 +- src/Jobs/Stages/SwitchToNewAndRemoveOldIndex.php | 2 +- tests/Integration/Jobs/Stages/CreateWriteIndexTest.php | 2 +- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fb2b4c97..8f540447 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/) ## [Unreleased] +## [2.0.3] - 2019-08-26 +### Fixed +- Elasticsearch 7.2 compatibility + ## [2.0.2] - 2019-05-10 ### Added - Search amongst multiple models diff --git a/composer.json b/composer.json index ceae1bec..471b5fa0 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "matchish/laravel-scout-elasticsearch", "description": "This package extends Laravel Scout adding full power of ElasticSearch", - "version": "2.0.2", + "version": "2.0.3", "keywords": [ "laravel", "scout", @@ -18,7 +18,7 @@ ], "require": { "php": "^7.1.3", - "elasticsearch/elasticsearch": ">=7.0 <7.2", + "elasticsearch/elasticsearch": ">=7.2", "laravel/scout": "^6.1.1|^7.0", "ongr/elasticsearch-dsl": "^6.0" }, diff --git a/src/Jobs/Stages/CleanUp.php b/src/Jobs/Stages/CleanUp.php index 9dd69379..f02687cd 100644 --- a/src/Jobs/Stages/CleanUp.php +++ b/src/Jobs/Stages/CleanUp.php @@ -34,7 +34,7 @@ public function handle(Client $elasticsearch): void $params = GetAliasParams::anyIndex($searchable->searchableAs()); try { /** @var array $response */ - $response = $elasticsearch->indices()->getAliases($params->toArray()); + $response = $elasticsearch->indices()->getAlias($params->toArray()); } catch (Missing404Exception $e) { $response = []; } diff --git a/src/Jobs/Stages/SwitchToNewAndRemoveOldIndex.php b/src/Jobs/Stages/SwitchToNewAndRemoveOldIndex.php index 7457b662..0a0ad513 100644 --- a/src/Jobs/Stages/SwitchToNewAndRemoveOldIndex.php +++ b/src/Jobs/Stages/SwitchToNewAndRemoveOldIndex.php @@ -38,7 +38,7 @@ public function handle(Client $elasticsearch): void $searchable = $this->searchable; $params = Get::anyIndex($searchable->searchableAs()); /** @var array $response */ - $response = $elasticsearch->indices()->getAliases($params->toArray()); + $response = $elasticsearch->indices()->getAlias($params->toArray()); $params = new Update(); foreach ($response as $indexName => $alias) { diff --git a/tests/Integration/Jobs/Stages/CreateWriteIndexTest.php b/tests/Integration/Jobs/Stages/CreateWriteIndexTest.php index 0877a117..6d07e550 100644 --- a/tests/Integration/Jobs/Stages/CreateWriteIndexTest.php +++ b/tests/Integration/Jobs/Stages/CreateWriteIndexTest.php @@ -17,7 +17,7 @@ public function test_create_write_index(): void $elasticsearch = $this->app->make(Client::class); $stage = new CreateWriteIndex(new Product(), Index::fromSearchable(new Product())); $stage->handle($elasticsearch); - $response = $elasticsearch->indices()->getAliases(['index' => '*', 'name' => 'products']); + $response = $elasticsearch->indices()->getAlias(['index' => '*', 'name' => 'products']); $this->assertTrue($this->containsWriteIndex($response, 'products')); } From 2760f77ad9d4a49153b4da4bddd69b7fefe89d4d Mon Sep 17 00:00:00 2001 From: Sergey Shlyakhov Date: Tue, 27 Aug 2019 06:53:43 +0300 Subject: [PATCH 20/39] Revert version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 471b5fa0..2ea0825f 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "matchish/laravel-scout-elasticsearch", "description": "This package extends Laravel Scout adding full power of ElasticSearch", - "version": "2.0.3", + "version": "2.0.2", "keywords": [ "laravel", "scout", From c13b00224dcb8daf29f2bc0dbff27efc8f2e0657 Mon Sep 17 00:00:00 2001 From: Sergey Shlyakhov Date: Tue, 27 Aug 2019 06:55:13 +0300 Subject: [PATCH 21/39] Revert changelog --- CHANGELOG.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f540447..fb2b4c97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,10 +6,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/) ## [Unreleased] -## [2.0.3] - 2019-08-26 -### Fixed -- Elasticsearch 7.2 compatibility - ## [2.0.2] - 2019-05-10 ### Added - Search amongst multiple models From 6e16ec20150207d3d6332b7ff2182e599cc385a1 Mon Sep 17 00:00:00 2001 From: Matthew Koppel Date: Tue, 3 Sep 2019 17:45:49 -0700 Subject: [PATCH 22/39] Replace hardcoded EloquentHitsIteratorAggregate to an interface --- src/ElasticSearch/HitsIteratorAggregate.php | 10 ++++++ src/ElasticSearchServiceProvider.php | 5 +++ src/Engines/ElasticSearchEngine.php | 9 +++-- .../HitsIteratorAggregateTest.php | 33 +++++++++++++++++++ .../library/CustomHitsIteratorAggregate.php | 26 +++++++++++++++ 5 files changed, 80 insertions(+), 3 deletions(-) create mode 100644 src/ElasticSearch/HitsIteratorAggregate.php create mode 100644 tests/Integration/Elasticsearch/HitsIteratorAggregateTest.php create mode 100644 tests/laravel/app/library/CustomHitsIteratorAggregate.php diff --git a/src/ElasticSearch/HitsIteratorAggregate.php b/src/ElasticSearch/HitsIteratorAggregate.php new file mode 100644 index 00000000..3687daba --- /dev/null +++ b/src/ElasticSearch/HitsIteratorAggregate.php @@ -0,0 +1,10 @@ +app->bind(Client::class, function () { return ClientBuilder::create()->setHosts([config('elasticsearch.host')])->build(); }); + + $this->app->bind( + 'Matchish\ScoutElasticSearch\ElasticSearch\HitsIteratorAggregate', + 'Matchish\ScoutElasticSearch\ElasticSearch\EloquentHitsIteratorAggregate' + ); } /** diff --git a/src/Engines/ElasticSearchEngine.php b/src/Engines/ElasticSearchEngine.php index 2edfb3f9..b6a01ca3 100644 --- a/src/Engines/ElasticSearchEngine.php +++ b/src/Engines/ElasticSearchEngine.php @@ -11,8 +11,8 @@ use Matchish\ScoutElasticSearch\ElasticSearch\Params\Bulk; use Matchish\ScoutElasticSearch\ElasticSearch\SearchFactory; use Matchish\ScoutElasticSearch\ElasticSearch\SearchResults; +use Matchish\ScoutElasticSearch\ElasticSearch\HitsIteratorAggregate; use Matchish\ScoutElasticSearch\ElasticSearch\Params\Indices\Refresh; -use Matchish\ScoutElasticSearch\ElasticSearch\EloquentHitsIteratorAggregate; use Matchish\ScoutElasticSearch\ElasticSearch\Params\Search as SearchParams; final class ElasticSearchEngine extends Engine @@ -27,7 +27,7 @@ final class ElasticSearchEngine extends Engine /** * Create a new engine instance. * - * @param \Elasticsearch\Client $elasticsearch + * @param \Elasticsearch\Client $elasticsearch * @return void */ public function __construct(\Elasticsearch\Client $elasticsearch) @@ -102,7 +102,10 @@ public function mapIds($results) */ public function map(BaseBuilder $builder, $results, $model) { - $hits = new EloquentHitsIteratorAggregate($results, $builder->queryCallback); + $hits = app()->makeWith(HitsIteratorAggregate::class, + ['results' => $results, + 'callback' => $builder->queryCallback, + ]); return new Collection($hits); } diff --git a/tests/Integration/Elasticsearch/HitsIteratorAggregateTest.php b/tests/Integration/Elasticsearch/HitsIteratorAggregateTest.php new file mode 100644 index 00000000..3a0a5028 --- /dev/null +++ b/tests/Integration/Elasticsearch/HitsIteratorAggregateTest.php @@ -0,0 +1,33 @@ +app->makeWith(HitsIteratorAggregate::class, [ + 'results' => [], + 'callback' => null, + ]); + + $this->assertEquals(EloquentHitsIteratorAggregate::class, get_class($iteratorAggregate)); + } + + public function test_override_bind_for_custom_iterator_aggregate_implementation() + { + $this->app->bind(HitsIteratorAggregate::class, CustomHitsIteratorAggregate::class); + + $iteratorAggregate = $this->app->makeWith(HitsIteratorAggregate::class, [ + 'results' => [], + 'callback' => null, + ]); + + $this->assertEquals(CustomHitsIteratorAggregate::class, get_class($iteratorAggregate)); + } +} diff --git a/tests/laravel/app/library/CustomHitsIteratorAggregate.php b/tests/laravel/app/library/CustomHitsIteratorAggregate.php new file mode 100644 index 00000000..3f140de4 --- /dev/null +++ b/tests/laravel/app/library/CustomHitsIteratorAggregate.php @@ -0,0 +1,26 @@ +results = $results; + + $this->callback = $callback; + } + + public function getIterator() + { + $hits = ['test1', 'test2', 'test3']; + + return new \ArrayIterator($hits); + } +} From f265eb45cb93a7cc6a45d6972fff48c8c01d5eaf Mon Sep 17 00:00:00 2001 From: Matthew Koppel Date: Mon, 9 Sep 2019 12:17:47 -0700 Subject: [PATCH 23/39] Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fb2b4c97..7821e235 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/) ## [Unreleased] +## [2.0.3] - 2019-09-09 +### Added +- Added interface binding for HitsIteratorAggregate for custom implementation + ## [2.0.2] - 2019-05-10 ### Added - Search amongst multiple models From d64c1fce486b7225e5dc90da5d84c92cbadac996 Mon Sep 17 00:00:00 2001 From: Sergey Shlyakhov Date: Fri, 27 Sep 2019 07:06:53 +0000 Subject: [PATCH 24/39] Apply fixes from StyleCI --- src/ElasticSearch/HitsIteratorAggregate.php | 20 +++---- .../library/CustomHitsIteratorAggregate.php | 52 +++++++++---------- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/ElasticSearch/HitsIteratorAggregate.php b/src/ElasticSearch/HitsIteratorAggregate.php index 3687daba..20032ea4 100644 --- a/src/ElasticSearch/HitsIteratorAggregate.php +++ b/src/ElasticSearch/HitsIteratorAggregate.php @@ -1,10 +1,10 @@ -results = $results; - - $this->callback = $callback; - } - - public function getIterator() - { - $hits = ['test1', 'test2', 'test3']; - - return new \ArrayIterator($hits); - } -} +results = $results; + + $this->callback = $callback; + } + + public function getIterator() + { + $hits = ['test1', 'test2', 'test3']; + + return new \ArrayIterator($hits); + } +} From 771277592725d7dc8c6e67ab33e914517c64b4ce Mon Sep 17 00:00:00 2001 From: Sergey Shlyakhov Date: Wed, 9 Oct 2019 06:14:33 +0300 Subject: [PATCH 25/39] Update ongr/elasticsearch-dsl package Use ongr/elasticsearch-dsl ^7.0 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 2ea0825f..780eb045 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "php": "^7.1.3", "elasticsearch/elasticsearch": ">=7.2", "laravel/scout": "^6.1.1|^7.0", - "ongr/elasticsearch-dsl": "^6.0" + "ongr/elasticsearch-dsl": "^7.0" }, "require-dev": { "fzaninotto/faker": "^1.8", From 533bf4c42285e9450aa3469cfa0368229fa12c5c Mon Sep 17 00:00:00 2001 From: Sergey Shliakhov Date: Sun, 17 Nov 2019 06:44:08 +0200 Subject: [PATCH 26/39] Import missing class --- src/Engines/ElasticSearchEngine.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Engines/ElasticSearchEngine.php b/src/Engines/ElasticSearchEngine.php index a13b4d5d..5f2b83ea 100644 --- a/src/Engines/ElasticSearchEngine.php +++ b/src/Engines/ElasticSearchEngine.php @@ -7,7 +7,7 @@ use Laravel\Scout\Builder as BaseBuilder; use Laravel\Scout\Engines\Engine; use Laravel\Scout\Searchable; -use Matchish\ScoutElasticSearch\ElasticSearch\EloquentHitsIteratorAggregate; +use Matchish\ScoutElasticSearch\ElasticSearch\HitsIteratorAggregate; use Matchish\ScoutElasticSearch\ElasticSearch\Params\Bulk; use Matchish\ScoutElasticSearch\ElasticSearch\Params\Indices\Refresh; use Matchish\ScoutElasticSearch\ElasticSearch\Params\Search as SearchParams; From a65310b6afc31926de17ff49866530ccb1719144 Mon Sep 17 00:00:00 2001 From: Sergey Shliakhov Date: Sun, 17 Nov 2019 06:45:05 +0200 Subject: [PATCH 27/39] Polish --- tests/TestCase.php | 2 +- tests/Unit/Engines/ElasticSearchEngineTest.php | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/TestCase.php b/tests/TestCase.php index 630fedbd..a236aaea 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -47,7 +47,7 @@ protected function getEnvironmentSetUp($app) 'type' => 'integer', ], ], - ]); + ]); } protected function getPackageProviders($app) diff --git a/tests/Unit/Engines/ElasticSearchEngineTest.php b/tests/Unit/Engines/ElasticSearchEngineTest.php index 27d51b00..ca886efe 100644 --- a/tests/Unit/Engines/ElasticSearchEngineTest.php +++ b/tests/Unit/Engines/ElasticSearchEngineTest.php @@ -7,7 +7,6 @@ use Laravel\Scout\Builder; use Matchish\ScoutElasticSearch\Engines\ElasticSearchEngine; use Mockery as m; -use ONGR\ElasticsearchDSL\Search; use Tests\TestCase; class ElasticSearchEngineTest extends TestCase From a09ba090ad02b394aeee65cce64a3c30dd4ce997 Mon Sep 17 00:00:00 2001 From: Sergey Shliakhov Date: Sun, 17 Nov 2019 06:46:32 +0200 Subject: [PATCH 28/39] Fix path to totals --- tests/Feature/ImportCommandTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Feature/ImportCommandTest.php b/tests/Feature/ImportCommandTest.php index 361e39b5..22ca3e0d 100644 --- a/tests/Feature/ImportCommandTest.php +++ b/tests/Feature/ImportCommandTest.php @@ -115,7 +115,7 @@ public function test_import_with_custom_key_all_pages(): void ], ]; $response = $this->elasticsearch->search($params); - $this->assertEquals($booksAmount, $response['hits']['total']); + $this->assertEquals($booksAmount, $response['hits']['total']['value']); } public function test_remove_old_index_after_switching_to_new(): void From 0b8338604d09ddbec1d492f7b451e350c75d0c06 Mon Sep 17 00:00:00 2001 From: Sergey Shliakhov Date: Sun, 17 Nov 2019 06:47:20 +0200 Subject: [PATCH 29/39] Bump version --- Makefile | 2 +- README.md | 16 ++++++++++++---- composer.json | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 38faeb17..ebb73c81 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ help: ## Show this help up: ## Start all containers (in background) for development sudo sysctl -w vm.max_map_count=262144 - $(docker_compose_bin) up --no-recreate -d + $(docker_compose_bin) up -d down: ## Stop all started for development containers $(docker_compose_bin) down diff --git a/README.md b/README.md index a2081150..17c3e698 100644 --- a/README.md +++ b/README.md @@ -25,12 +25,13 @@ great features, and at the same time leverage the complete set of ElasticSearch If you need any help, [stack overflow](https://stackoverflow.com/questions/tagged/laravel-scout%20laravel%20elasticsearch) is the preferred and recommended way to ask support questions. -## :two_hearts: Features +## :two_hearts: Features +Don't forget to :star: the package if you like it. :pray: - [Search amongst multiple models](#search-amongst-multiple-models) - [**Zero downtime** reimport](#zero-downtime-reimport) - it’s a breeze to import data in production. - [Eager load relations](#eager-load) - speed up your import. -- Elasticsearch **7.0** ready - Use [elasticsearch-7](https://github.com/matchish/laravel-scout-elasticsearch/tree/elasticsearch-7) branch instead. +- Elasticsearch **7.0** ready - Import all searchable models at once. - A fully configurable mapping for each model. - Full power of ElasticSearch in your queries. @@ -39,7 +40,11 @@ If you need any help, [stack overflow](https://stackoverflow.com/questions/tagge - PHP version >= 7.1.3 - Laravel Framework version >= 5.6 -- Elasticsearch version >= 6 + +| Elasticsearch version | ElasticsearchDSL version | +| --------------------- | --------------------------- | +| >= 7.0 | >= 3.0.0 | +| >= 6.0, < 7.0 | < 3.0.0 | ## :rocket: Installation @@ -190,7 +195,10 @@ Mixed::search('title:Barcelona or to:Barcelona') In this example you will get collection of `Ticket` and `Book` models where ticket's arrival city or book title is `Barcelona` ->Don't forget to :star: the package if you like it. :pray: +###Working with results +Often your response isn't collection of models but aggregations or models with higlights an so on. +In this case you need to implement your own implementation of `HitsIteratorAggregate` and bind it in your service provider +(case)[https://github.com/matchish/laravel-scout-elasticsearch/issues/28] ## :free: License Scout ElasticSearch is an open-sourced software licensed under the [MIT license](LICENSE.md). diff --git a/composer.json b/composer.json index acc91829..afd73744 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "matchish/laravel-scout-elasticsearch", "description": "This package extends Laravel Scout adding full power of ElasticSearch", - "version": "2.1.0", + "version": "3.0.0", "keywords": [ "laravel", "scout", From b82b84ab054d6bc8c220ebcd715d1db40acc6287 Mon Sep 17 00:00:00 2001 From: Sergey Shliakhov Date: Sun, 17 Nov 2019 06:52:31 +0200 Subject: [PATCH 30/39] Fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 17c3e698..4094e3cf 100644 --- a/README.md +++ b/README.md @@ -195,7 +195,7 @@ Mixed::search('title:Barcelona or to:Barcelona') In this example you will get collection of `Ticket` and `Book` models where ticket's arrival city or book title is `Barcelona` -###Working with results +### Working with results Often your response isn't collection of models but aggregations or models with higlights an so on. In this case you need to implement your own implementation of `HitsIteratorAggregate` and bind it in your service provider (case)[https://github.com/matchish/laravel-scout-elasticsearch/issues/28] From 8486522c72b9af5a884cd0f9a15f28a043b9974a Mon Sep 17 00:00:00 2001 From: Sergey Shliakhov Date: Sun, 17 Nov 2019 06:54:09 +0200 Subject: [PATCH 31/39] Fix link format --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4094e3cf..68726738 100644 --- a/README.md +++ b/README.md @@ -198,7 +198,7 @@ book title is `Barcelona` ### Working with results Often your response isn't collection of models but aggregations or models with higlights an so on. In this case you need to implement your own implementation of `HitsIteratorAggregate` and bind it in your service provider -(case)[https://github.com/matchish/laravel-scout-elasticsearch/issues/28] +[case](https://github.com/matchish/laravel-scout-elasticsearch/issues/28) ## :free: License Scout ElasticSearch is an open-sourced software licensed under the [MIT license](LICENSE.md). From 0e8263377cf2d21808319593ad507a3a3a7f1cf4 Mon Sep 17 00:00:00 2001 From: Sergey Shliakhov Date: Sun, 17 Nov 2019 06:55:14 +0200 Subject: [PATCH 32/39] Polish --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 68726738..4ee73293 100644 --- a/README.md +++ b/README.md @@ -198,7 +198,8 @@ book title is `Barcelona` ### Working with results Often your response isn't collection of models but aggregations or models with higlights an so on. In this case you need to implement your own implementation of `HitsIteratorAggregate` and bind it in your service provider -[case](https://github.com/matchish/laravel-scout-elasticsearch/issues/28) + +[Here is a case](https://github.com/matchish/laravel-scout-elasticsearch/issues/28) ## :free: License Scout ElasticSearch is an open-sourced software licensed under the [MIT license](LICENSE.md). From 723f4bc0e89ad3c086bd2627732a9ba7bb7ad1ac Mon Sep 17 00:00:00 2001 From: Sergey Shlyakhov Date: Sun, 17 Nov 2019 05:01:18 +0000 Subject: [PATCH 33/39] Apply fixes from StyleCI --- tests/Integration/Elasticsearch/HitsIteratorAggregateTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Integration/Elasticsearch/HitsIteratorAggregateTest.php b/tests/Integration/Elasticsearch/HitsIteratorAggregateTest.php index 3a0a5028..6a89eca4 100644 --- a/tests/Integration/Elasticsearch/HitsIteratorAggregateTest.php +++ b/tests/Integration/Elasticsearch/HitsIteratorAggregateTest.php @@ -2,10 +2,10 @@ namespace Matchish\ScoutElasticSearch; -use Tests\TestCase; use App\Library\CustomHitsIteratorAggregate; -use Matchish\ScoutElasticSearch\ElasticSearch\HitsIteratorAggregate; use Matchish\ScoutElasticSearch\ElasticSearch\EloquentHitsIteratorAggregate; +use Matchish\ScoutElasticSearch\ElasticSearch\HitsIteratorAggregate; +use Tests\TestCase; class HitsIteratorAggregateTest extends TestCase { From 084d8c92c869548e372068679cec3252d0b0ea23 Mon Sep 17 00:00:00 2001 From: Sergey Shliakhov Date: Sun, 17 Nov 2019 07:20:57 +0200 Subject: [PATCH 34/39] Ignore error --- phpstan.neon.dist | 3 +++ 1 file changed, 3 insertions(+) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 6ef936f3..bbf0ecb9 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -12,3 +12,6 @@ parameters: - path: %currentWorkingDirectory%/src/Engines/ElasticSearchEngine.php message: '#message.*ServerErrorResponseException constructor expects string, string|false given.#' + - + path: %currentWorkingDirectory%/src/Engines/ElasticSearchEngine.php + message: '#Parameter \#2 \$search of function array_key_exists expects array, array\|\(callable\) given\.#' From 5318da9dcb299813fbce5ffcac9e039dcd26776c Mon Sep 17 00:00:00 2001 From: Sergey Shlyakhov Date: Mon, 18 Nov 2019 09:45:49 +0200 Subject: [PATCH 35/39] Update Elasticsearch to 7.4.2 --- .scrutinizer.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 4bc0ba42..4f0a98a5 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -23,7 +23,7 @@ build: nodes: analysis: services: - elasticsearch: 6.6.2 + elasticsearch: 7.4.2 mysql: 5.7 tests: override: From 2f30e10d0d992656cae732013304091643475119 Mon Sep 17 00:00:00 2001 From: Sergey Shlyakhov Date: Mon, 18 Nov 2019 10:06:14 +0200 Subject: [PATCH 36/39] Use getAlias instead of deprecated getAliases --- src/Jobs/Stages/SwitchToNewAndRemoveOldIndex.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Jobs/Stages/SwitchToNewAndRemoveOldIndex.php b/src/Jobs/Stages/SwitchToNewAndRemoveOldIndex.php index 9257a4c0..05b726de 100644 --- a/src/Jobs/Stages/SwitchToNewAndRemoveOldIndex.php +++ b/src/Jobs/Stages/SwitchToNewAndRemoveOldIndex.php @@ -36,7 +36,7 @@ public function handle(Client $elasticsearch): void { $source = $this->source; $params = Get::anyIndex($source->searchableAs()); - $response = $elasticsearch->indices()->getAliases($params->toArray()); + $response = $elasticsearch->indices()->getAlias($params->toArray()); $params = new Update(); foreach ($response as $indexName => $alias) { From f2768b24c3c1a17692ef18fdc26638aa1fc40f42 Mon Sep 17 00:00:00 2001 From: Sergey Shliakhov Date: Mon, 18 Nov 2019 10:45:48 +0200 Subject: [PATCH 37/39] Ignore error --- phpstan.neon.dist | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index bbf0ecb9..a98e09fc 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -15,3 +15,7 @@ parameters: - path: %currentWorkingDirectory%/src/Engines/ElasticSearchEngine.php message: '#Parameter \#2 \$search of function array_key_exists expects array, array\|\(callable\) given\.#' + - + path: %currentWorkingDirectory%/src/Engines/ElasticSearchEngine.php + message: 'Argument of an invalid type array\|\(callable\) supplied for foreach, only + iterables are supported\.' From 9884b02592d54fe6f1932ec8955738de7f88f1ff Mon Sep 17 00:00:00 2001 From: Sergey Shliakhov Date: Mon, 18 Nov 2019 11:30:01 +0200 Subject: [PATCH 38/39] Fix pattern syntax --- phpstan.neon.dist | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index a98e09fc..8da094b6 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -17,5 +17,5 @@ parameters: message: '#Parameter \#2 \$search of function array_key_exists expects array, array\|\(callable\) given\.#' - path: %currentWorkingDirectory%/src/Engines/ElasticSearchEngine.php - message: 'Argument of an invalid type array\|\(callable\) supplied for foreach, only - iterables are supported\.' + message: '#Argument of an invalid type array\|\(callable\) supplied for foreach, only + iterables are supported\.#' From c1e6191af72a65b30dd942ffd7f6bd2a89ddeafc Mon Sep 17 00:00:00 2001 From: Sergey Shliakhov Date: Mon, 18 Nov 2019 11:45:24 +0200 Subject: [PATCH 39/39] Fix path and pattern format --- phpstan.neon.dist | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 8da094b6..d20fdfcf 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -16,6 +16,5 @@ parameters: path: %currentWorkingDirectory%/src/Engines/ElasticSearchEngine.php message: '#Parameter \#2 \$search of function array_key_exists expects array, array\|\(callable\) given\.#' - - path: %currentWorkingDirectory%/src/Engines/ElasticSearchEngine.php - message: '#Argument of an invalid type array\|\(callable\) supplied for foreach, only - iterables are supported\.#' + path: %currentWorkingDirectory%/src/Jobs/Stages/SwitchToNewAndRemoveOldIndex.php + message: '#Argument of an invalid type array\|\(callable\) supplied for foreach, only iterables are supported\.#'