public function testFacadeReturnsInstance()
 {
     // App::make call
     $elastica = $this->app->make('elastica');
     $this->assertInstanceOf('Elastica\\Client', $elastica);
     // Facade call
     $index = \Es::getIndex('items');
     $this->assertInstanceOf('Elastica\\Client', $elastica);
 }
 public function playlistVideos()
 {
     $id = Input::get('id');
     $website_id = Input::get('website_id');
     $from = Input::get('from');
     $videosearch_params = array('index' => 'video-websites', 'type' => 'video');
     if (!empty($id)) {
         $videosearch_params['body']['query']['filtered']['query']['match']['playlist_id'] = $id;
     }
     $videosearch_params['body']['query']['filtered']['filter']['bool']['must'][]['term']['website_id'] = $website_id;
     $videosearch_params['body']['sort']['position']['order'] = 'asc';
     $videosearch_params['from'] = $from;
     $videosearch_response = Es::search($videosearch_params);
     return $videosearch_response;
 }
 public function setFeaturedVideo()
 {
     $id = Input::get('id');
     $website_id = Input::get('website_id');
     $playlist_id = Input::get('playlist_id');
     $status = Input::get('status');
     $featured = 'featured';
     if (!empty($status)) {
         $featured = '';
     }
     $user_id = Auth::user()->id;
     //unset all currently featured videos
     $videosearch_params = array('index' => 'video-websites', 'type' => 'video');
     if (!empty($playlist_id)) {
         $videosearch_params['body']['query']['filtered']['query']['match']['playlist_id'] = $playlist_id;
     }
     $videosearch_params['body']['query']['filtered']['filter']['bool']['must'][]['term']['user_id'] = $user_id;
     $videosearch_params['body']['query']['filtered']['filter']['bool']['must'][]['term']['website_id'] = $website_id;
     $videosearch_params['body']['query']['filtered']['filter']['bool']['must'][]['term']['featured'] = 'featured';
     $videosearch_response = Es::search($videosearch_params);
     $update_params = array('index' => 'video-websites', 'type' => 'video');
     foreach ($videosearch_response['hits']['hits'] as $hit) {
         $update_params['id'] = $hit['_id'];
         $source = $hit['_source'];
         $source['featured'] = '';
         $update_params['body']['doc'] = $source;
         $res = Es::update($update_params);
     }
     $get_params = array('index' => 'video-websites', 'type' => 'video', 'id' => $id);
     $video = Es::get($get_params);
     $source = $video['_source'];
     $source['featured'] = $featured;
     $update_params = array('index' => 'video-websites', 'type' => 'video', 'id' => $id, 'body' => array('doc' => $source));
     $response = Es::update($update_params);
     return $response;
 }
Beispiel #4
0
    $videosearch_response = Es::search($videosearch_params);
    return $videosearch_response;
});
Route::get('/vimeo/cache', function () {
    $user_id = 1;
    $video_page = 2;
    $website_id = 4;
    $channel_id = 4;
    $video_index = 21;
    $account_id = 'sayanee';
    $client = new GuzzleHttp\Client();
    do {
        $allvideos_response = $client->get("http://vimeo.com/api/v2/{$account_id}/all_videos.json?page={$video_page}");
        $videos = json_decode($allvideos_response->getBody(), true);
        if (!empty($videos)) {
            foreach ($videos as $video) {
                if ($video['embed_privacy'] == 'anywhere') {
                    $video_id = $video['id'];
                    $video_params['body'] = array('id' => $video_id, 'video_id' => $video_id, 'user_id' => $user_id, 'website_id' => $website_id, 'channel_id' => $channel_id, 'video_type' => 'vimeo', 'position' => $video_index, 'title' => $video['title'], 'description' => strip_tags($video['description']), 'thumbnail' => $video['thumbnail_small'], 'published_at' => date('Y-m-d', strtotime($video['upload_date'])));
                    $video_params['index'] = 'video-websites';
                    $video_params['type'] = 'video';
                    $video_params['id'] = $video_id;
                    $ret = Es::index($video_params);
                    print_r($ret);
                }
                $video_index += 1;
            }
        }
        $video_page += 1;
    } while (!empty($videos) && $video_page <= 3);
});
Beispiel #5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getEs()
 {
     return $this->hasMany(Es::className(), ['id_ge' => 'id']);
 }
Beispiel #6
0
 /**
  * Fetch the 'orphan' items
  * That's method that was used just ince to tag items that had no LD codes
  * Still, it shows how to just that
  *
  * @param int $from
  * @param int $size
  * @return array
  */
 public static function orphans($from = 0, $size = 20)
 {
     $searchParams['index'] = 'ciim';
     $searchParams['size'] = $size;
     $searchParams['from'] = $from;
     $filter = array();
     $filter['prefix'] = array('_id' => 'ht');
     $query = array('wildcard' => array('summary_title' => "**"));
     $searchParams['body']['query']['filtered'] = array("filter" => $filter, "query" => $query);
     $result = \Es::search($searchParams);
     return $result;
 }