# HG changeset patch # User ymh # Date 1268418141 -3600 # Node ID 28c8f4908e3f3698d5a671937f0ce35674b43b6f # Parent 8f7f6284556267ae61825daad3844358e96af6ba add solr search diff -r 8f7f62845562 -r 28c8f4908e3f web/thdProject/apps/frontend/config/app.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/apps/frontend/config/app.yml Fri Mar 12 19:22:21 2010 +0100 @@ -0,0 +1,11 @@ +# default values +all: + storage: + #segmentation files + uploads: "/Users/ymh/dev/workspace/mosatags/web/thdProject/web/uploads" + format: ".csv" + + player: + videoPath: "videos/" + +#dev: diff -r 8f7f62845562 -r 28c8f4908e3f web/thdProject/apps/frontend/modules/homepage/actions/actions.class.php --- a/web/thdProject/apps/frontend/modules/homepage/actions/actions.class.php Wed Mar 10 17:19:00 2010 +0100 +++ b/web/thdProject/apps/frontend/modules/homepage/actions/actions.class.php Fri Mar 12 19:22:21 2010 +0100 @@ -21,5 +21,17 @@ { return sfView::SUCCESS; } - + +/** + * Execute search action + * + * @param sfRequest $request A request object + */ + public function executeSearch(sfWebRequest $request) + { + return sfView::SUCCESS; + + } + + } diff -r 8f7f62845562 -r 28c8f4908e3f web/thdProject/apps/frontend/modules/homepage/actions/components.class.php --- a/web/thdProject/apps/frontend/modules/homepage/actions/components.class.php Wed Mar 10 17:19:00 2010 +0100 +++ b/web/thdProject/apps/frontend/modules/homepage/actions/components.class.php Fri Mar 12 19:22:21 2010 +0100 @@ -39,4 +39,46 @@ $this->mostTaggedFilms = $query->execute(); $this->videoPath = sfConfig::get('app_player_videoPath'); } + + public function executeResultList(sfWebRequest $request) { + + $text = $request->getParameter('text'); + + $event = $this->dispatcher->notify(new sfEvent($this, 'uvmc_solr.search', array('query' => $text))); + $response = $event->getReturnValue(); + // solr is configured to give you back a serialized php array + $rawResp = $response->getRawResponse(); + $results = unserialize($rawResp); + + + + $primaryKeys = array(); + foreach($results['response']['docs'] as $doc) + { + if($doc['uniqueid']) + { + $primaryKeys[] = $doc['uniqueid']; + } + } + + if(!empty($primaryKeys)) + { + $this->searchResult = Doctrine::getTable('ThdFilm')->findByScoredId($primaryKeys); + $this->searchCount = $this->searchResult->count(); + } + else + { + $this->searchResult = array(); + $this->searchCount = 0; + } + + + /*$query = Doctrine_Query::create() + ->from('ThdFilm F') + ->leftJoin('F.images I ') + ->leftJoin('F.videos V') + ->orderBy('F.id DESC') + ->limit(0,10); + $this->searchResult = $query->execute();*/ + } } \ No newline at end of file diff -r 8f7f62845562 -r 28c8f4908e3f web/thdProject/apps/frontend/modules/homepage/templates/_resultList.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/apps/frontend/modules/homepage/templates/_resultList.php Fri Mar 12 19:22:21 2010 +0100 @@ -0,0 +1,53 @@ +
+

Films resultats de la recherche

+

Search length :

+ +
\ No newline at end of file diff -r 8f7f62845562 -r 28c8f4908e3f web/thdProject/apps/frontend/modules/homepage/templates/_search.php --- a/web/thdProject/apps/frontend/modules/homepage/templates/_search.php Wed Mar 10 17:19:00 2010 +0100 +++ b/web/thdProject/apps/frontend/modules/homepage/templates/_search.php Fri Mar 12 19:22:21 2010 +0100 @@ -2,7 +2,7 @@

Recherche classique :

-
+
diff -r 8f7f62845562 -r 28c8f4908e3f web/thdProject/apps/frontend/modules/homepage/templates/searchSuccess.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/apps/frontend/modules/homepage/templates/searchSuccess.php Fri Mar 12 19:22:21 2010 +0100 @@ -0,0 +1,27 @@ + +
+ +
+ +
+
+ + +
+
+ \ No newline at end of file diff -r 8f7f62845562 -r 28c8f4908e3f web/thdProject/config/databases.yml --- a/web/thdProject/config/databases.yml Wed Mar 10 17:19:00 2010 +0100 +++ b/web/thdProject/config/databases.yml Fri Mar 12 19:22:21 2010 +0100 @@ -4,4 +4,4 @@ param: dsn: 'mysql:host=localhost;dbname=thd' username: root - password: null + password: root diff -r 8f7f62845562 -r 28c8f4908e3f web/thdProject/lib/model/doctrine/ThdFilmTable.class.php --- a/web/thdProject/lib/model/doctrine/ThdFilmTable.class.php Wed Mar 10 17:19:00 2010 +0100 +++ b/web/thdProject/lib/model/doctrine/ThdFilmTable.class.php Fri Mar 12 19:22:21 2010 +0100 @@ -5,4 +5,17 @@ class ThdFilmTable extends Doctrine_Table { + public function findByScoredId($ids) + { + $query = $this->createQuery('p'); + $query->select('p.*') + ->whereIn('p.uniqueid', $ids) + // Keep scoring + // http://groups.google.com/group/symfony-users/browse_thread/thread/92adb0332dfe1065/ee7b8c0d27208368?lnk=gst&q=zend+search+sort#ee7b8c0d27208368 + ->addSelect('FIELD(p.uniqueid,\''.implode('\', \'', $ids).'\') AS field') + ->orderBy('field'); + + return $query->execute(); + } + } \ No newline at end of file