예제 #1
0
 public function addGiftcodeintoSolrDocument($id_name)
 {
     try {
         $giftcode = $this->jqxGet('codes_name', 'id_name', $id_name);
         if (empty($giftcode) === FALSE) {
             $this->config->load('solr');
             $solr = $this->config->item('solr');
             $options = array('hostname' => $solr['SOLR_SERVER_HOSTNAME'], 'login' => $solr['SOLR_SERVER_USERNAME'], 'password' => $solr['SOLR_SERVER_PASSWORD'], 'port' => $solr['SOLR_SERVER_PORT'], 'path' => 'solr/giftcode');
             $client = new SolrClient($options);
             if ($giftcode['status'] == 1) {
                 $doc = new SolrInputDocument();
                 $doc->addField('id_name', $giftcode['id_name']);
                 $doc->addField('name', $giftcode['name']);
                 $doc->addField('image', $giftcode['image']);
                 $doc->addField('create_time', $giftcode['create_time']);
                 $doc->addField('seo_keyword', $giftcode['seo_keyword']);
                 $doc->addField('id_game', $giftcode['id_game']);
                 $doc->addField('total', $giftcode['total']);
                 $doc->addField('uses', $giftcode['uses']);
                 $doc->addField('content', strip_tags(preg_replace('/<script\\b[^>]*>(.*?)<\\/script>/is', "", $giftcode['content'])));
                 $game = $this->m_backend->jqxGet('game', 'id_game', $giftcode['id_game']);
                 empty($game) === FALSE ? $doc->addField('full_name', $game['full_name']) : $doc->addField('full_name', '');
                 $updateResponse = $client->addDocument($doc);
                 $client->commit();
                 return $updateResponse->getResponse();
             } else {
                 $client->deleteById($giftcode['id_name']);
                 return $client->commit();
             }
         } else {
             return FALSE;
         }
     } catch (Exception $e) {
         return FALSE;
     }
 }
예제 #2
0
 /**
  * Remove search result from the index.
  * @param $id
  * @return bool
  */
 public function removeIndex($id)
 {
     $this->client->deleteById($id);
     $this->commit();
 }
예제 #3
0
 public function addListGametoSolr()
 {
     try {
         $games = $this->m_backend->jqxGets('game');
         if (empty($games) === FALSE) {
             $this->config->load('solr');
             $solr = $this->config->item('solr');
             $options = array('hostname' => $solr['SOLR_SERVER_HOSTNAME'], 'login' => $solr['SOLR_SERVER_USERNAME'], 'password' => $solr['SOLR_SERVER_PASSWORD'], 'port' => $solr['SOLR_SERVER_PORT'], 'path' => 'solr/game');
             $client = new SolrClient($options);
             foreach ($games as $game) {
                 if ($game['status'] == 1) {
                     $doc = new SolrInputDocument();
                     $doc->addField('id_game', $game['id_game']);
                     $doc->addField('full_name', $game['full_name']);
                     $doc->addField('logo_game', $game['logo_game']);
                     $doc->addField('rate_public', $game['rate_public']);
                     $doc->addField('full_name_vn', $game['full_name_vn']);
                     $doc->addField('description', $game['description']);
                     $doc->addField('keyword', $game['keyword']);
                     $doc->addField('id_game_category', $game['id_game_category']);
                     $doc->addField('id_publisher', $game['id_publisher']);
                     $doc->addField('platform', $game['platform']);
                     $doc->addField('url_download', $game['url_download']);
                     $doc->addField('content', strip_tags(preg_replace('/<script\\b[^>]*>(.*?)<\\/script>/is', "", $game['content'])));
                     $game_category = $this->m_backend->jqxGet('game_category', 'id_game_category', $game['id_game_category']);
                     empty($game_category) === FALSE ? $doc->addField('title', $game_category['title']) : $doc->addField('title', '');
                     $publisher = $this->m_backend->jqxGet('publisher', 'id_publisher', $game['id_publisher']);
                     empty($publisher) === FALSE ? $doc->addField('publisher', $publisher['full_name']) : $doc->addField('publisher', '');
                     $updateResponse = $client->addDocument($doc);
                     $client->commit();
                 } else {
                     $client->deleteById($game['id_game']);
                     $client->commit();
                 }
             }
         } else {
             return FALSE;
         }
     } catch (Exception $e) {
         return FALSE;
     }
 }
예제 #4
0
 /**
  * Removes the given entity from the solr index
  * 
  * @param object $entity
  */
 public function removeEntity($entity)
 {
     $this->client->deleteById($this->getSolrId($entity));
     $this->client->commit();
 }