diff --git a/src/DesignMyNight/Elasticsearch/EloquentBuilder.php b/src/DesignMyNight/Elasticsearch/EloquentBuilder.php index 17e6f21..ff57502 100644 --- a/src/DesignMyNight/Elasticsearch/EloquentBuilder.php +++ b/src/DesignMyNight/Elasticsearch/EloquentBuilder.php @@ -25,7 +25,7 @@ public function setModel(Model $model) $this->query->from($model->getSearchIndex()); - $this->query->whereType($model->getSearchType()); + $this->query->type($model->getSearchType()); return $this; } diff --git a/src/DesignMyNight/Elasticsearch/Searchable.php b/src/DesignMyNight/Elasticsearch/Searchable.php index 0f02a6c..c13ace0 100644 --- a/src/DesignMyNight/Elasticsearch/Searchable.php +++ b/src/DesignMyNight/Elasticsearch/Searchable.php @@ -3,6 +3,7 @@ namespace DesignMyNight\Elasticsearch; trait Searchable { + public static function getElasticsearchConnectionName(): string { return 'elasticsearch'; @@ -127,6 +128,8 @@ public static function newElasticsearchQuery(): EloquentBuilder { $model = new static(); - return $model->on(static::getElasticsearchConnectionName())->setModel($model); + return $model + ->on(static::getElasticsearchConnectionName()) + ->whereType($model->getSearchType()); } -} \ No newline at end of file +}