Skip to content

Instantly share code, notes, and snippets.

@marksparrish
Last active November 15, 2021 19:40
Show Gist options
  • Save marksparrish/cd9d7dfc74cc18ce8f3bfd089cf61531 to your computer and use it in GitHub Desktop.
Save marksparrish/cd9d7dfc74cc18ce8f3bfd089cf61531 to your computer and use it in GitHub Desktop.
Laravel Elasticsearch Builder Class
<?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