From 9daa8a6667e99ef1c7f07d29e80d832cb223081e Mon Sep 17 00:00:00 2001 From: Tyler Date: Sun, 27 Dec 2020 02:53:41 -0500 Subject: [PATCH] Rollback PHP to 7.4 --- Dockerfile | 2 +- app/Models/Author.php | 20 ++++++++++++++++++++ app/Models/Location.php | 20 ++++++++++++++++++++ app/Services/Search/AuthorConfigurator.php | 14 ++++++++++++++ app/Services/Search/BookConfigurator.php | 8 -------- app/Services/Search/LocationConfigurator.php | 14 ++++++++++++++ public/mix-manifest.json | 4 ++++ 7 files changed, 73 insertions(+), 9 deletions(-) create mode 100644 app/Services/Search/AuthorConfigurator.php create mode 100644 app/Services/Search/LocationConfigurator.php create mode 100644 public/mix-manifest.json diff --git a/Dockerfile b/Dockerfile index 2cd8a28..822b18b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,3 @@ -FROM php:8-fpm-alpine +FROM php:7.4-fpm-alpine RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer diff --git a/app/Models/Author.php b/app/Models/Author.php index 2009539..cfb42d1 100644 --- a/app/Models/Author.php +++ b/app/Models/Author.php @@ -2,10 +2,16 @@ namespace App\Models; +use App\Services\Search\AuthorConfigurator; use Illuminate\Database\Eloquent\Model; +use ScoutElastic\Searchable; class Author extends Model { + use Searchable; + + protected $indexConfigurator = AuthorConfigurator::class; + /** * The attributes that are mass assignable. * @@ -18,4 +24,18 @@ class Author extends Model { public function books() { return $this->belongsToMany(Book::class); } + + protected $mapping = [ + 'properties' => [ + 'name' => [ + 'type' => 'text', + // Also you can configure multi-fields, more details you can find here https://www.elastic.co/guide/en/elasticsearch/reference/current/multi-fields.html + 'fields' => [ + 'raw' => [ + 'type' => 'keyword', + ] + ] + ], + ] + ]; } diff --git a/app/Models/Location.php b/app/Models/Location.php index 6fc3a54..81ebf2b 100644 --- a/app/Models/Location.php +++ b/app/Models/Location.php @@ -2,10 +2,16 @@ namespace App\Models; +use App\Services\Search\LocationConfigurator; use Illuminate\Database\Eloquent\Model; +use ScoutElastic\Searchable; class Location extends Model { + use Searchable; + + protected $indexConfigurator = LocationConfigurator::class; + /** * The attributes that are mass assignable. * @@ -18,4 +24,18 @@ class Location extends Model { public function books() { return $this->hasMany(Book::class); } + + protected $mapping = [ + 'properties' => [ + 'name' => [ + 'type' => 'text', + // Also you can configure multi-fields, more details you can find here https://www.elastic.co/guide/en/elasticsearch/reference/current/multi-fields.html + 'fields' => [ + 'raw' => [ + 'type' => 'keyword', + ] + ] + ], + ] + ]; } diff --git a/app/Services/Search/AuthorConfigurator.php b/app/Services/Search/AuthorConfigurator.php new file mode 100644 index 0000000..8e6dcf6 --- /dev/null +++ b/app/Services/Search/AuthorConfigurator.php @@ -0,0 +1,14 @@ + [ - 'analyzer' => [ - 'es_std' => [ - 'type' => 'standard', - 'stopwords' => '_spanish_' - ] - ] - ] ]; } \ No newline at end of file diff --git a/app/Services/Search/LocationConfigurator.php b/app/Services/Search/LocationConfigurator.php new file mode 100644 index 0000000..e6aaa57 --- /dev/null +++ b/app/Services/Search/LocationConfigurator.php @@ -0,0 +1,14 @@ +