. */ namespace Poniverse\Ponyfm\Http\Controllers\Api\Web; use Elasticsearch; use Poniverse\Ponyfm\Http\Controllers\ApiControllerBase; use Input; use Response; class SearchController extends ApiControllerBase { public function getSearch() { $input = Input::all(); $elasticsearch = Elasticsearch::connection(); $results = $elasticsearch->search([ 'index' => 'ponyfm', 'type' => 'track,album', 'body' => [ 'query' => [ 'multi_match' => [ 'query' => $input['query'], 'fields' => [ 'track.title', 'album.title', 'track.artist', 'album.artist', 'track.genre', ] ] ] ] ]); return Response::json([ 'results' => $results, ], 200); } }