/** * Build search query. * * @param SearchableContract $model It's a model. * @param string $term Term / keyword you want to search. * @param array $fields An array contains which fields you want to lookup upon a search. * * @return array */ protected function buildSearchQuery(SearchableContract $model, $term, array $fields = []) { return ['index' => $model->getIndexableName(), 'type' => $model->getIndexableType(), 'body' => ['query' => ['multi_match' => ['query' => $term, 'fields' => $fields === [] ? $model->getSearchableColumns() : $fields]]]]; }
/** * Delete all index based on an eloquent model instance. * * @param Searchable $model * * @return array */ public function nuke(Searchable $model) { return $this->client->deleteByQuery(['index' => $model->getIndexableName(), 'type' => $model->getIndexableType(), 'body' => ['query' => ['match_all' => []]]]); }