Last active
November 15, 2021 19:40
-
-
Save marksparrish/cd9d7dfc74cc18ce8f3bfd089cf61531 to your computer and use it in GitHub Desktop.
Laravel Elasticsearch Builder Class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Elastic\Builders; | |
use App\Elastic\ElasticEngine; | |
// This is the generic builder class that extends the ElasticEngine | |
class Builder extends ElasticEngine | |
{ | |
public function __construct($model) | |
{ | |
$this->model = $model; | |
parent::__construct(); | |
} | |
public function mustMatchAll() | |
{ | |
$this->setMustQuery('match_all', ["boost" => 1]); | |
return $this; | |
} | |
public function mappings() { | |
return [ | |
'index' => $this->index, | |
'body' => [ | |
'settings' => [ | |
'number_of_shards' => 1, | |
'number_of_replicas' => 0, | |
] | |
] | |
]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment