Ejemplo n.º 1
0
 public function _sphinx_index()
 {
     $config = new Sphinx_Conf(__CLASS__);
     $config->sql_query = "\n            SELECT film_id, title, description, release_year, language_id, rental_duration, rental_rate, length, replacement_cost, rating, special_features, UNIX_TIMESTAMP(last_update) as last_update\n            FROM film";
     $config->sql_attr_uint = 'release_year';
     $config->sql_attr_uint = 'rental_duration';
     $config->sql_attr_uint = 'language_id';
     $config->sql_attr_uint = 'length';
     $config->sql_attr_float = 'rental_rate';
     $config->sql_attr_float = 'replacement_cost';
     $config->sql_attr_timestamp = 'last_update';
     $config->index();
     return $config;
 }
Ejemplo n.º 2
0
 public function _sphinx_index()
 {
     // Create Source
     $config = new Sphinx_Conf(__CLASS__);
     /*
     $config->sql_query = "
         SELECT actor_id, CONCAT(first_name, ' ', last_name) as sort_name, first_name, last_name, UNIX_TIMESTAMP(last_update) as last_update
         FROM `actor`";
     */
     $config->sql_query = "\n            SELECT `actor`.`actor_id`, first_name as sort_fname, last_name as sort_lname, first_name, last_name, UNIX_TIMESTAMP(actor.last_update) as last_update, count(film_actor.film_id) as films\n            FROM `actor`\n            INNER JOIN `film_actor` ON `film_actor`.`actor_id` = `actor`.`actor_id`\n            GROUP BY `actor`.`actor_id`";
     // Attributes
     $config->sql_attr_str2ordinal = 'sort_fname';
     $config->sql_attr_str2ordinal = 'sort_lname';
     $config->sql_attr_timestamp = 'last_update';
     $config->sql_attr_uint = 'films';
     $index = new Sphinx_Index();
     $config->index($index);
     return $config;
 }
Ejemplo n.º 3
0
 public function action_test3()
 {
     $config = new Sphinx_Conf('film_text');
     $config->sql_query = "\n            SELECT film_id, title, title as sort_title, description\n            FROM `film_text`";
     $config->sql_attr_str2ordinal = 'sort_title';
     // Adds Default Index Conf
     $config->index();
     $search = Sphinx::factory($config);
     echo '<h3>Passing Sphinx_Conf object instead of normal model</h3>
         <br/><form method="post"><input name="query" value="' . (isset($_POST['query']) ? $_POST['query'] : 'goldfinger') . '"><input type="submit"/></form>';
     if (!isset($_POST['query'])) {
         echo '<pre>';
         echo $search->run_index();
         echo '</pre>';
     } else {
         $search->query = $_POST['query'];
         $search->limit = 20;
         echo Kohana::debug($search->results);
     }
 }