#1: Progress commit - some semblance of this is working now.

This commit is contained in:
Peter Deltchev 2016-01-14 22:20:28 -08:00
parent e0faefee23
commit 990916171c
7 changed files with 315 additions and 154 deletions

View file

@ -23,34 +23,16 @@ namespace Poniverse\Ponyfm\Http\Controllers\Api\Web;
use Elasticsearch; use Elasticsearch;
use Poniverse\Ponyfm\Http\Controllers\ApiControllerBase; use Poniverse\Ponyfm\Http\Controllers\ApiControllerBase;
use Input; use Input;
use Poniverse\Ponyfm\Library\Search;
use Response; use Response;
class SearchController extends ApiControllerBase class SearchController extends ApiControllerBase
{ {
public function getSearch() public function getSearch(Search $search)
{ {
$input = Input::all(); $input = Input::all();
$elasticsearch = Elasticsearch::connection(); $results = $search->searchAllContent($input['query']);
$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([ return Response::json([
'results' => $results, 'results' => $results,

160
app/Library/Search.php Normal file
View file

@ -0,0 +1,160 @@
<?php
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2016 Peter Deltchev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Poniverse\Ponyfm\Library;
use DB;
use Elasticsearch\Client;
use Illuminate\Database\Eloquent\Collection;
use Poniverse\Ponyfm\Models\Album;
use Poniverse\Ponyfm\Models\Playlist;
use Poniverse\Ponyfm\Models\Track;
use Poniverse\Ponyfm\Models\User;
class Search {
protected $elasticsearch;
protected $index;
public function __construct(Client $connection, string $indexName) {
$this->elasticsearch = $connection;
$this->index = $indexName;
}
/**
* @param string $query
* @param int $resultsPerContentType
* @return array
*/
public function searchAllContent(string $query, int $resultsPerContentType = 10) {
$results = $this->elasticsearch->msearch([
'index' => $this->index,
'body' => [
//===== Tracks=====//
['type' => 'track'],
[
'query' => [
'multi_match' => [
'query' => $query,
'fields' => [
'title',
'artist',
'genre',
'track_type',
'show_songs',
],
],
],
'size' => $resultsPerContentType
],
//===== Albums =====//
['type' => 'album'],
[
'query' => [
'multi_match' => [
'query' => $query,
'fields' => [
'title',
'artist',
'tracks',
],
],
],
'size' => $resultsPerContentType
],
//===== Playlists =====//
['type' => 'playlist'],
[
'query' => [
'multi_match' => [
'query' => $query,
'fields' => [
'title',
'user',
],
],
],
'size' => $resultsPerContentType
],
//===== Users =====//
['type' => 'user'],
[
'query' => [
'multi_match' => [
'query' => $query,
'fields' => [
'display_name',
],
],
],
'size' => $resultsPerContentType
],
]
]);
$tracks = $this->transformToEloquent(Track::class, $results['responses'][0]['hits']['hits']);
$albums = $this->transformToEloquent(Album::class, $results['responses'][1]['hits']['hits']);
$playlists = $this->transformToEloquent(Playlist::class, $results['responses'][2]['hits']['hits']);
$users = $this->transformToEloquent(User::class, $results['responses'][3]['hits']['hits']);
return [
'tracks' => $tracks,
'albums' => $albums,
'playlists' => $playlists,
'users' => $users
];
}
/**
* Transforms the given Elasticsearch results into a collection of corresponding
* Eloquent models.
*
* This method assumes that the given class uses soft deletes.
*
* @param string $modelClass The Eloquent model class to instantiate these results as
* @param array $searchHits
* @return \Illuminate\Database\Eloquent\Collection
*/
protected function transformToEloquent(string $modelClass, array $searchHits) {
if (empty($searchHits)) {
return new Collection();
}
$ids = [];
$caseStatement = 'CASE id ';
$i = 0;
foreach ($searchHits as $result) {
$ids[$result['_id']] = $result['_score'];
$caseStatement .= "WHEN ${result['_id']} THEN $i ";
$i++;
}
$caseStatement .= 'END';
$modelInstances = $modelClass::withTrashed()
->whereIn('id', array_keys($ids))
->orderBy(DB::raw($caseStatement))
->get();
return $modelInstances;
}
}

View file

@ -831,6 +831,8 @@ class Track extends Model
return 'track-' . $this->id . '-' . $key; return 'track-' . $this->id . '-' . $key;
} }
//============= Elasticsearch stuff ==================//
public function toElasticsearch() { public function toElasticsearch() {
return [ return [
'title' => $this->title, 'title' => $this->title,

View file

@ -20,8 +20,6 @@
namespace Poniverse\Ponyfm\Providers; namespace Poniverse\Ponyfm\Providers;
use DB;
use Illuminate\Database\SQLiteConnection;
use Illuminate\Foundation\Application; use Illuminate\Foundation\Application;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
use PfmValidator; use PfmValidator;
@ -53,5 +51,12 @@ class AppServiceProvider extends ServiceProvider
$this->app->bind(Poniverse::class, function(Application $app) { $this->app->bind(Poniverse::class, function(Application $app) {
return new Poniverse($app['config']->get('poniverse.client_id'), $app['config']->get('poniverse.secret')); return new Poniverse($app['config']->get('poniverse.client_id'), $app['config']->get('poniverse.secret'));
}); });
$this->app->bind(Poniverse\Ponyfm\Library\Search::class, function(Application $app) {
return new Poniverse\Ponyfm\Library\Search(
\Elasticsearch::connection(),
$app['config']->get('ponyfm.elasticsearch_index')
);
});
} }
} }

254
composer.lock generated
View file

@ -376,33 +376,33 @@
}, },
{ {
"name": "doctrine/cache", "name": "doctrine/cache",
"version": "v1.5.4", "version": "v1.6.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/doctrine/cache.git", "url": "https://github.com/doctrine/cache.git",
"reference": "47cdc76ceb95cc591d9c79a36dc3794975b5d136" "reference": "f8af318d14bdb0eff0336795b428b547bd39ccb6"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/doctrine/cache/zipball/47cdc76ceb95cc591d9c79a36dc3794975b5d136", "url": "https://api.github.com/repos/doctrine/cache/zipball/f8af318d14bdb0eff0336795b428b547bd39ccb6",
"reference": "47cdc76ceb95cc591d9c79a36dc3794975b5d136", "reference": "f8af318d14bdb0eff0336795b428b547bd39ccb6",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=5.3.2" "php": "~5.5|~7.0"
}, },
"conflict": { "conflict": {
"doctrine/common": ">2.2,<2.4" "doctrine/common": ">2.2,<2.4"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": ">=3.7", "phpunit/phpunit": "~4.8|~5.0",
"predis/predis": "~1.0", "predis/predis": "~1.0",
"satooshi/php-coveralls": "~0.6" "satooshi/php-coveralls": "~0.6"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "1.5.x-dev" "dev-master": "1.6.x-dev"
} }
}, },
"autoload": { "autoload": {
@ -442,7 +442,7 @@
"cache", "cache",
"caching" "caching"
], ],
"time": "2015-12-19 05:03:47" "time": "2015-12-31 16:37:02"
}, },
{ {
"name": "doctrine/collections", "name": "doctrine/collections",
@ -512,16 +512,16 @@
}, },
{ {
"name": "doctrine/common", "name": "doctrine/common",
"version": "v2.5.2", "version": "v2.6.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/doctrine/common.git", "url": "https://github.com/doctrine/common.git",
"reference": "311001fd9865a4d0d59efff4eac6d7dcb3f5270c" "reference": "a579557bc689580c19fee4e27487a67fe60defc0"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/doctrine/common/zipball/311001fd9865a4d0d59efff4eac6d7dcb3f5270c", "url": "https://api.github.com/repos/doctrine/common/zipball/a579557bc689580c19fee4e27487a67fe60defc0",
"reference": "311001fd9865a4d0d59efff4eac6d7dcb3f5270c", "reference": "a579557bc689580c19fee4e27487a67fe60defc0",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -530,20 +530,20 @@
"doctrine/collections": "1.*", "doctrine/collections": "1.*",
"doctrine/inflector": "1.*", "doctrine/inflector": "1.*",
"doctrine/lexer": "1.*", "doctrine/lexer": "1.*",
"php": ">=5.3.2" "php": "~5.5|~7.0"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "~3.7" "phpunit/phpunit": "~4.8|~5.0"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "2.5.x-dev" "dev-master": "2.7.x-dev"
} }
}, },
"autoload": { "autoload": {
"psr-0": { "psr-4": {
"Doctrine\\Common\\": "lib/" "Doctrine\\Common\\": "lib/Doctrine/Common"
} }
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
@ -581,24 +581,24 @@
"persistence", "persistence",
"spl" "spl"
], ],
"time": "2015-12-04 12:49:42" "time": "2015-12-25 13:18:31"
}, },
{ {
"name": "doctrine/dbal", "name": "doctrine/dbal",
"version": "v2.5.2", "version": "v2.5.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/doctrine/dbal.git", "url": "https://github.com/doctrine/dbal.git",
"reference": "01dbcbc5cd0a913d751418e635434a18a2f2a75c" "reference": "abbdfd1cff43a7b99d027af3be709bc8fc7d4769"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/doctrine/dbal/zipball/01dbcbc5cd0a913d751418e635434a18a2f2a75c", "url": "https://api.github.com/repos/doctrine/dbal/zipball/abbdfd1cff43a7b99d027af3be709bc8fc7d4769",
"reference": "01dbcbc5cd0a913d751418e635434a18a2f2a75c", "reference": "abbdfd1cff43a7b99d027af3be709bc8fc7d4769",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"doctrine/common": ">=2.4,<2.6-dev", "doctrine/common": ">=2.4,<2.7-dev",
"php": ">=5.3.2" "php": ">=5.3.2"
}, },
"require-dev": { "require-dev": {
@ -652,7 +652,7 @@
"persistence", "persistence",
"queryobject" "queryobject"
], ],
"time": "2015-09-16 16:29:33" "time": "2016-01-05 22:11:12"
}, },
{ {
"name": "doctrine/inflector", "name": "doctrine/inflector",
@ -777,16 +777,16 @@
}, },
{ {
"name": "elasticsearch/elasticsearch", "name": "elasticsearch/elasticsearch",
"version": "v2.1.3", "version": "v2.0.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/elastic/elasticsearch-php.git", "url": "https://github.com/elastic/elasticsearch-php.git",
"reference": "7086a86cab241a77f19cdd653ae3d2e023b41699" "reference": "9ce5bd7606f6c185d434de4f80863f998f74e179"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/elastic/elasticsearch-php/zipball/7086a86cab241a77f19cdd653ae3d2e023b41699", "url": "https://api.github.com/repos/elastic/elasticsearch-php/zipball/9ce5bd7606f6c185d434de4f80863f998f74e179",
"reference": "7086a86cab241a77f19cdd653ae3d2e023b41699", "reference": "9ce5bd7606f6c185d434de4f80863f998f74e179",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -797,8 +797,8 @@
"require-dev": { "require-dev": {
"athletic/athletic": "~0.1", "athletic/athletic": "~0.1",
"cpliakas/git-wrapper": "~1.0", "cpliakas/git-wrapper": "~1.0",
"mockery/mockery": "0.9.4", "mockery/mockery": "dev-master@dev",
"phpunit/phpunit": "~4.7", "phpunit/phpunit": "3.7.*",
"symfony/yaml": "2.4.3 as 2.4.2", "symfony/yaml": "2.4.3 as 2.4.2",
"twig/twig": "1.*" "twig/twig": "1.*"
}, },
@ -827,7 +827,7 @@
"elasticsearch", "elasticsearch",
"search" "search"
], ],
"time": "2015-12-15 18:42:26" "time": "2015-11-05 15:29:21"
}, },
{ {
"name": "guzzlehttp/guzzle", "name": "guzzlehttp/guzzle",
@ -1333,16 +1333,16 @@
}, },
{ {
"name": "laravel/framework", "name": "laravel/framework",
"version": "v5.1.27", "version": "v5.1.28",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/laravel/framework.git", "url": "https://github.com/laravel/framework.git",
"reference": "b16f80878fd3603022d3c84593397cedd9af0bcf" "reference": "3f0fd27939dfdafb1e50058423cd24e640894ba2"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/laravel/framework/zipball/b16f80878fd3603022d3c84593397cedd9af0bcf", "url": "https://api.github.com/repos/laravel/framework/zipball/3f0fd27939dfdafb1e50058423cd24e640894ba2",
"reference": "b16f80878fd3603022d3c84593397cedd9af0bcf", "reference": "3f0fd27939dfdafb1e50058423cd24e640894ba2",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1457,7 +1457,7 @@
"framework", "framework",
"laravel" "laravel"
], ],
"time": "2015-12-17 20:35:38" "time": "2015-12-31 17:41:30"
}, },
{ {
"name": "league/flysystem", "name": "league/flysystem",
@ -1764,16 +1764,16 @@
}, },
{ {
"name": "paragonie/random_compat", "name": "paragonie/random_compat",
"version": "1.1.4", "version": "1.1.5",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/paragonie/random_compat.git", "url": "https://github.com/paragonie/random_compat.git",
"reference": "d762ee5b099a29044603cd4649851e81aa66cb47" "reference": "dd8998b7c846f6909f4e7a5f67fabebfc412a4f7"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/paragonie/random_compat/zipball/d762ee5b099a29044603cd4649851e81aa66cb47", "url": "https://api.github.com/repos/paragonie/random_compat/zipball/dd8998b7c846f6909f4e7a5f67fabebfc412a4f7",
"reference": "d762ee5b099a29044603cd4649851e81aa66cb47", "reference": "dd8998b7c846f6909f4e7a5f67fabebfc412a4f7",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1808,7 +1808,7 @@
"pseudorandom", "pseudorandom",
"random" "random"
], ],
"time": "2015-12-10 14:48:13" "time": "2016-01-06 13:31:20"
}, },
{ {
"name": "pda/pheanstalk", "name": "pda/pheanstalk",
@ -2167,16 +2167,16 @@
}, },
{ {
"name": "symfony/class-loader", "name": "symfony/class-loader",
"version": "v2.8.0", "version": "v2.8.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/class-loader.git", "url": "https://github.com/symfony/class-loader.git",
"reference": "51f83451bf0ddfc696e47e4642d6cd10fcfce160" "reference": "98e9089a428ed0e39423b67352c57ef5910a3269"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/class-loader/zipball/51f83451bf0ddfc696e47e4642d6cd10fcfce160", "url": "https://api.github.com/repos/symfony/class-loader/zipball/98e9089a428ed0e39423b67352c57ef5910a3269",
"reference": "51f83451bf0ddfc696e47e4642d6cd10fcfce160", "reference": "98e9089a428ed0e39423b67352c57ef5910a3269",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2215,20 +2215,20 @@
], ],
"description": "Symfony ClassLoader Component", "description": "Symfony ClassLoader Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2015-11-26 07:00:59" "time": "2016-01-03 15:33:41"
}, },
{ {
"name": "symfony/console", "name": "symfony/console",
"version": "v2.7.7", "version": "v2.7.9",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/console.git", "url": "https://github.com/symfony/console.git",
"reference": "16bb1cb86df43c90931df65f529e7ebd79636750" "reference": "d3fc138b6ed8f8074591821d3416d8f9c04d6ca6"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/16bb1cb86df43c90931df65f529e7ebd79636750", "url": "https://api.github.com/repos/symfony/console/zipball/d3fc138b6ed8f8074591821d3416d8f9c04d6ca6",
"reference": "16bb1cb86df43c90931df65f529e7ebd79636750", "reference": "d3fc138b6ed8f8074591821d3416d8f9c04d6ca6",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2274,20 +2274,20 @@
], ],
"description": "Symfony Console Component", "description": "Symfony Console Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2015-11-18 09:54:26" "time": "2016-01-14 08:26:43"
}, },
{ {
"name": "symfony/css-selector", "name": "symfony/css-selector",
"version": "v2.7.7", "version": "v2.7.9",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/css-selector.git", "url": "https://github.com/symfony/css-selector.git",
"reference": "abb47717fb88aebd9437da2fc8bb01a50a36679f" "reference": "1a869e59cc3b2802961fc2124139659e12b72fe5"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/css-selector/zipball/abb47717fb88aebd9437da2fc8bb01a50a36679f", "url": "https://api.github.com/repos/symfony/css-selector/zipball/1a869e59cc3b2802961fc2124139659e12b72fe5",
"reference": "abb47717fb88aebd9437da2fc8bb01a50a36679f", "reference": "1a869e59cc3b2802961fc2124139659e12b72fe5",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2327,20 +2327,20 @@
], ],
"description": "Symfony CssSelector Component", "description": "Symfony CssSelector Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2015-10-30 20:10:21" "time": "2016-01-03 15:32:00"
}, },
{ {
"name": "symfony/debug", "name": "symfony/debug",
"version": "v2.7.7", "version": "v2.7.9",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/debug.git", "url": "https://github.com/symfony/debug.git",
"reference": "0dbc119596f4afc82d9b2eb2a7e6a4af1ee763fa" "reference": "5aca4aa9600b943287b4a1799a4d1d78b5388175"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/debug/zipball/0dbc119596f4afc82d9b2eb2a7e6a4af1ee763fa", "url": "https://api.github.com/repos/symfony/debug/zipball/5aca4aa9600b943287b4a1799a4d1d78b5388175",
"reference": "0dbc119596f4afc82d9b2eb2a7e6a4af1ee763fa", "reference": "5aca4aa9600b943287b4a1799a4d1d78b5388175",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2384,20 +2384,20 @@
], ],
"description": "Symfony Debug Component", "description": "Symfony Debug Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2015-10-30 20:10:21" "time": "2016-01-13 07:57:33"
}, },
{ {
"name": "symfony/dom-crawler", "name": "symfony/dom-crawler",
"version": "v2.7.7", "version": "v2.7.9",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/dom-crawler.git", "url": "https://github.com/symfony/dom-crawler.git",
"reference": "b33593cbfe1d81b50d48353f338aca76a08658d8" "reference": "55cc79a177193eb3bd74ac54b353691fbb211d3a"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/dom-crawler/zipball/b33593cbfe1d81b50d48353f338aca76a08658d8", "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/55cc79a177193eb3bd74ac54b353691fbb211d3a",
"reference": "b33593cbfe1d81b50d48353f338aca76a08658d8", "reference": "55cc79a177193eb3bd74ac54b353691fbb211d3a",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2439,20 +2439,20 @@
], ],
"description": "Symfony DomCrawler Component", "description": "Symfony DomCrawler Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2015-11-02 20:20:53" "time": "2016-01-03 15:32:00"
}, },
{ {
"name": "symfony/event-dispatcher", "name": "symfony/event-dispatcher",
"version": "v2.8.0", "version": "v2.8.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/event-dispatcher.git", "url": "https://github.com/symfony/event-dispatcher.git",
"reference": "a5eb815363c0388e83247e7e9853e5dbc14999cc" "reference": "ee278f7c851533e58ca307f66305ccb9188aceda"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/a5eb815363c0388e83247e7e9853e5dbc14999cc", "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/ee278f7c851533e58ca307f66305ccb9188aceda",
"reference": "a5eb815363c0388e83247e7e9853e5dbc14999cc", "reference": "ee278f7c851533e58ca307f66305ccb9188aceda",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2499,20 +2499,20 @@
], ],
"description": "Symfony EventDispatcher Component", "description": "Symfony EventDispatcher Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2015-10-30 20:15:42" "time": "2016-01-13 10:28:07"
}, },
{ {
"name": "symfony/finder", "name": "symfony/finder",
"version": "v2.7.7", "version": "v2.7.9",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/finder.git", "url": "https://github.com/symfony/finder.git",
"reference": "a06a0c0ff7db3736a50d530c908cca547bf13da9" "reference": "d20ac81c81a67ab898b0c0afa435f3e9a7d460cf"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/a06a0c0ff7db3736a50d530c908cca547bf13da9", "url": "https://api.github.com/repos/symfony/finder/zipball/d20ac81c81a67ab898b0c0afa435f3e9a7d460cf",
"reference": "a06a0c0ff7db3736a50d530c908cca547bf13da9", "reference": "d20ac81c81a67ab898b0c0afa435f3e9a7d460cf",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2548,20 +2548,20 @@
], ],
"description": "Symfony Finder Component", "description": "Symfony Finder Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2015-10-30 20:10:21" "time": "2016-01-14 08:26:43"
}, },
{ {
"name": "symfony/http-foundation", "name": "symfony/http-foundation",
"version": "v2.7.7", "version": "v2.7.9",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/http-foundation.git", "url": "https://github.com/symfony/http-foundation.git",
"reference": "e83a3d105ddaf5a113e803c904fdec552d1f1c35" "reference": "2f9d240056f026af5f7ba7f7052b0c6709bf288c"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/e83a3d105ddaf5a113e803c904fdec552d1f1c35", "url": "https://api.github.com/repos/symfony/http-foundation/zipball/2f9d240056f026af5f7ba7f7052b0c6709bf288c",
"reference": "e83a3d105ddaf5a113e803c904fdec552d1f1c35", "reference": "2f9d240056f026af5f7ba7f7052b0c6709bf288c",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2603,20 +2603,20 @@
], ],
"description": "Symfony HttpFoundation Component", "description": "Symfony HttpFoundation Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2015-11-20 17:41:18" "time": "2016-01-13 10:26:43"
}, },
{ {
"name": "symfony/http-kernel", "name": "symfony/http-kernel",
"version": "v2.7.7", "version": "v2.7.9",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/http-kernel.git", "url": "https://github.com/symfony/http-kernel.git",
"reference": "5570de31e8fbc03777a8c61eb24f9b626e5e5941" "reference": "aa2f1e544d6cb862452504b5479a5095b7bfc53f"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/http-kernel/zipball/5570de31e8fbc03777a8c61eb24f9b626e5e5941", "url": "https://api.github.com/repos/symfony/http-kernel/zipball/aa2f1e544d6cb862452504b5479a5095b7bfc53f",
"reference": "5570de31e8fbc03777a8c61eb24f9b626e5e5941", "reference": "aa2f1e544d6cb862452504b5479a5095b7bfc53f",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2685,20 +2685,20 @@
], ],
"description": "Symfony HttpKernel Component", "description": "Symfony HttpKernel Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2015-11-23 11:57:49" "time": "2016-01-14 10:41:45"
}, },
{ {
"name": "symfony/polyfill-php56", "name": "symfony/polyfill-php56",
"version": "v1.0.0", "version": "v1.0.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/polyfill-php56.git", "url": "https://github.com/symfony/polyfill-php56.git",
"reference": "a6bd4770a6967517e6610529e14afaa3111094a3" "reference": "e2e77609a9e2328eb370fbb0e0d8b2000ebb488f"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php56/zipball/a6bd4770a6967517e6610529e14afaa3111094a3", "url": "https://api.github.com/repos/symfony/polyfill-php56/zipball/e2e77609a9e2328eb370fbb0e0d8b2000ebb488f",
"reference": "a6bd4770a6967517e6610529e14afaa3111094a3", "reference": "e2e77609a9e2328eb370fbb0e0d8b2000ebb488f",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2741,11 +2741,11 @@
"portable", "portable",
"shim" "shim"
], ],
"time": "2015-11-04 20:28:58" "time": "2015-12-18 15:10:25"
}, },
{ {
"name": "symfony/polyfill-util", "name": "symfony/polyfill-util",
"version": "v1.0.0", "version": "v1.0.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/polyfill-util.git", "url": "https://github.com/symfony/polyfill-util.git",
@ -2797,16 +2797,16 @@
}, },
{ {
"name": "symfony/process", "name": "symfony/process",
"version": "v2.7.7", "version": "v2.7.9",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/process.git", "url": "https://github.com/symfony/process.git",
"reference": "f6290983c8725d0afa29bdc3e5295879de3e58f5" "reference": "0570b9ca51135ee7da0f19239eaf7b07ffb87034"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/process/zipball/f6290983c8725d0afa29bdc3e5295879de3e58f5", "url": "https://api.github.com/repos/symfony/process/zipball/0570b9ca51135ee7da0f19239eaf7b07ffb87034",
"reference": "f6290983c8725d0afa29bdc3e5295879de3e58f5", "reference": "0570b9ca51135ee7da0f19239eaf7b07ffb87034",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2842,20 +2842,20 @@
], ],
"description": "Symfony Process Component", "description": "Symfony Process Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2015-11-19 16:11:24" "time": "2016-01-06 09:57:37"
}, },
{ {
"name": "symfony/routing", "name": "symfony/routing",
"version": "v2.7.7", "version": "v2.7.9",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/routing.git", "url": "https://github.com/symfony/routing.git",
"reference": "7450f6196711b124fb8b04a12286d01a0401ddfe" "reference": "6fec77993acfe19aecf60544b9c7d32f3d5b2506"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/routing/zipball/7450f6196711b124fb8b04a12286d01a0401ddfe", "url": "https://api.github.com/repos/symfony/routing/zipball/6fec77993acfe19aecf60544b9c7d32f3d5b2506",
"reference": "7450f6196711b124fb8b04a12286d01a0401ddfe", "reference": "6fec77993acfe19aecf60544b9c7d32f3d5b2506",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2915,20 +2915,20 @@
"uri", "uri",
"url" "url"
], ],
"time": "2015-11-18 13:41:01" "time": "2016-01-03 15:32:00"
}, },
{ {
"name": "symfony/translation", "name": "symfony/translation",
"version": "v2.7.7", "version": "v2.7.9",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/translation.git", "url": "https://github.com/symfony/translation.git",
"reference": "e4ecb9c3ba1304eaf24de15c2d7a428101c1982f" "reference": "8cbab8445ad4269427077ba02fff8718cb397e22"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/translation/zipball/e4ecb9c3ba1304eaf24de15c2d7a428101c1982f", "url": "https://api.github.com/repos/symfony/translation/zipball/8cbab8445ad4269427077ba02fff8718cb397e22",
"reference": "e4ecb9c3ba1304eaf24de15c2d7a428101c1982f", "reference": "8cbab8445ad4269427077ba02fff8718cb397e22",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2978,20 +2978,20 @@
], ],
"description": "Symfony Translation Component", "description": "Symfony Translation Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2015-11-18 13:41:01" "time": "2016-01-03 15:32:00"
}, },
{ {
"name": "symfony/var-dumper", "name": "symfony/var-dumper",
"version": "v2.7.7", "version": "v2.7.9",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/var-dumper.git", "url": "https://github.com/symfony/var-dumper.git",
"reference": "72bcb27411780eaee9469729aace73c0d46fb2b8" "reference": "ad39199e91f2f845a0181b14d459fda13a622138"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/72bcb27411780eaee9469729aace73c0d46fb2b8", "url": "https://api.github.com/repos/symfony/var-dumper/zipball/ad39199e91f2f845a0181b14d459fda13a622138",
"reference": "72bcb27411780eaee9469729aace73c0d46fb2b8", "reference": "ad39199e91f2f845a0181b14d459fda13a622138",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -3037,20 +3037,20 @@
"debug", "debug",
"dump" "dump"
], ],
"time": "2015-11-18 13:41:01" "time": "2016-01-07 11:12:32"
}, },
{ {
"name": "venturecraft/revisionable", "name": "venturecraft/revisionable",
"version": "1.24.0", "version": "1.26.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/VentureCraft/revisionable.git", "url": "https://github.com/VentureCraft/revisionable.git",
"reference": "99c27d94f80ae9240cec89c4276f61e748e989a5" "reference": "7a3d5304de6c10d43cfb0d9ebe0bbdbb6e5b82ee"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/VentureCraft/revisionable/zipball/99c27d94f80ae9240cec89c4276f61e748e989a5", "url": "https://api.github.com/repos/VentureCraft/revisionable/zipball/7a3d5304de6c10d43cfb0d9ebe0bbdbb6e5b82ee",
"reference": "99c27d94f80ae9240cec89c4276f61e748e989a5", "reference": "7a3d5304de6c10d43cfb0d9ebe0bbdbb6e5b82ee",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -3085,7 +3085,7 @@
"model", "model",
"revision" "revision"
], ],
"time": "2015-12-09 21:48:10" "time": "2016-01-13 12:14:05"
}, },
{ {
"name": "vlucas/phpdotenv", "name": "vlucas/phpdotenv",
@ -3387,16 +3387,16 @@
}, },
{ {
"name": "phpspec/phpspec", "name": "phpspec/phpspec",
"version": "2.4.0", "version": "2.4.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpspec/phpspec.git", "url": "https://github.com/phpspec/phpspec.git",
"reference": "1d3938e6d9ffb1bd4805ea8ddac62ea48767f358" "reference": "5528ce1e93a1efa090c9404aba3395c329b4e6ed"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpspec/phpspec/zipball/1d3938e6d9ffb1bd4805ea8ddac62ea48767f358", "url": "https://api.github.com/repos/phpspec/phpspec/zipball/5528ce1e93a1efa090c9404aba3395c329b4e6ed",
"reference": "1d3938e6d9ffb1bd4805ea8ddac62ea48767f358", "reference": "5528ce1e93a1efa090c9404aba3395c329b4e6ed",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -3461,7 +3461,7 @@
"testing", "testing",
"tests" "tests"
], ],
"time": "2015-11-29 02:03:49" "time": "2016-01-01 10:17:54"
}, },
{ {
"name": "phpspec/prophecy", "name": "phpspec/prophecy",
@ -4264,16 +4264,16 @@
}, },
{ {
"name": "symfony/yaml", "name": "symfony/yaml",
"version": "v3.0.0", "version": "v3.0.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/yaml.git", "url": "https://github.com/symfony/yaml.git",
"reference": "177a015cb0e19ff4a49e0e2e2c5fc1c1bee07002" "reference": "3df409958a646dad2bc5046c3fb671ee24a1a691"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/177a015cb0e19ff4a49e0e2e2c5fc1c1bee07002", "url": "https://api.github.com/repos/symfony/yaml/zipball/3df409958a646dad2bc5046c3fb671ee24a1a691",
"reference": "177a015cb0e19ff4a49e0e2e2c5fc1c1bee07002", "reference": "3df409958a646dad2bc5046c3fb671ee24a1a691",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -4309,7 +4309,7 @@
], ],
"description": "Symfony Yaml Component", "description": "Symfony Yaml Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2015-11-30 12:36:17" "time": "2015-12-26 13:39:53"
} }
], ],
"aliases": [], "aliases": [],

View file

@ -56,7 +56,7 @@ return [
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Cache Duration | Cache duration
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| |
| Duration in minutes for track files to be stored in cache. | Duration in minutes for track files to be stored in cache.
@ -65,4 +65,15 @@ return [
'track_file_cache_duration' => 1440, 'track_file_cache_duration' => 1440,
/*
|--------------------------------------------------------------------------
| Elasticsearch index name
|--------------------------------------------------------------------------
|
| The name of the Elasticsearch index to store Pony.fm's search data in.
|
*/
'elasticsearch_index' => 'ponyfm',
]; ];

View file

@ -21,6 +21,7 @@
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Poniverse\Ponyfm\Console\Commands\RebuildSearchIndex; use Poniverse\Ponyfm\Console\Commands\RebuildSearchIndex;
use Poniverse\Ponyfm\Models\Track;
class SetupElasticsearch extends Migration class SetupElasticsearch extends Migration
{ {
@ -44,13 +45,13 @@ class SetupElasticsearch extends Migration
'title' => ['type' => 'string'], 'title' => ['type' => 'string'],
'artist' => ['type' => 'string'], 'artist' => ['type' => 'string'],
'published_at' => ['type' => 'date'], 'published_at' => ['type' => 'date'],
'genre' => ['type' => 'string'], 'genre' => ['type' => 'string', 'index' => 'not_analyzed'],
'track_type' => ['type' => 'string'], 'track_type' => ['type' => 'string', 'index' => 'not_analyzed'],
// This field is intended to be used as an array. // This field is intended to be used as an array.
// Note that all Elasticsearch fields can technically be used as arrays. // Note that all Elasticsearch fields can technically be used as arrays.
// See: https://www.elastic.co/guide/en/elasticsearch/reference/current/array.html // See: https://www.elastic.co/guide/en/elasticsearch/reference/current/array.html
'show_songs' => ['type' => 'string'], 'show_songs' => ['type' => 'string', 'index' => 'not_analyzed'],
] ]
], ],