diff --git a/src/Api/Controllers/SearchController.php b/src/Api/Controllers/SearchController.php index 92713f8..38d43e0 100644 --- a/src/Api/Controllers/SearchController.php +++ b/src/Api/Controllers/SearchController.php @@ -17,8 +17,6 @@ use Illuminate\Database\Eloquent\Collection; use Illuminate\Support\Arr; use Illuminate\Support\Str; use Psr\Http\Message\ServerRequestInterface; -use Spatie\ElasticsearchQueryBuilder\Aggregations\TermsAggregation; -use Spatie\ElasticsearchQueryBuilder\Aggregations\TopHitsAggregation; use Spatie\ElasticsearchQueryBuilder\Builder; use Spatie\ElasticsearchQueryBuilder\Queries\BoolQuery; use Spatie\ElasticsearchQueryBuilder\Queries\MatchQuery; @@ -59,12 +57,7 @@ class SearchController extends ListDiscussionsController ->from($this->extractOffset($request)) ->addQuery( $this->addFilters($filterQuery, $actor) - ) -// ->addAggregation( -// TermsAggregation::create('discussions', 'discussion_id') -// ->aggregation(TopHitsAggregation::create('hits', 1)) -// ) - ; + ); foreach ($this->extractSort($request) as $field => $direction) { $field = $this->translateSort[$field] ?? $field; diff --git a/src/Exceptions/SeedingException.php b/src/Exceptions/SeedingException.php new file mode 100644 index 0000000..549fc6f --- /dev/null +++ b/src/Exceptions/SeedingException.php @@ -0,0 +1,14 @@ + $body->toArray(), 'refresh' => true ]); + + if (Arr::get($response, 'errors') !== true) return true; + + $items = Arr::get($response, 'items'); + + $error = Arr::get(Arr::first($items), 'index.error.reason'); + + throw new SeedingException( + "Failed to seed: $error", + $items + ); } } diff --git a/src/Seeders/DiscussionSeeder.php b/src/Seeders/DiscussionSeeder.php index 4529c8e..a662ae4 100644 --- a/src/Seeders/DiscussionSeeder.php +++ b/src/Seeders/DiscussionSeeder.php @@ -62,7 +62,7 @@ class DiscussionSeeder extends Seeder } if ($this->extensionEnabled('flarum-sticky')) { - $document['is_sticky'] = $model->is_sticky; + $document['is_sticky'] = (bool) $model->is_sticky; } return $document;