plug solr search
authorymh <ymh.work@gmail.com>
Wed, 14 Apr 2010 18:20:32 +0200
changeset 52 cd141ba2fad8
parent 49 ec1fec8293ab
child 53 86c5f68fbaa8
plug solr search
engine/solr/solr/conf/schema.xml
web/thdProject/apps/backend/modules/film/actions/actions.class.php
web/thdProject/apps/frontend/modules/search/actions/viewSearchListAction.class.php
--- a/engine/solr/solr/conf/schema.xml	Wed Apr 14 18:13:17 2010 +0200
+++ b/engine/solr/solr/conf/schema.xml	Wed Apr 14 18:20:32 2010 +0200
@@ -95,7 +95,7 @@
    <field name="tags" type="tags"  indexed="true" stored="false" required="false" />
    <field name="directors" type="personsList"  indexed="true" stored="false" required="false" />
    <field name="actors" type="personsList"  indexed="true" stored="false" required="false" />
-   <field name="all" type="textdata" indexed="true" stored="false" required="false" multiValued="true" />    
+   <field name="all" type="textdata" indexed="true" stored="true" required="false" multiValued="true" />    
    
  </fields>
 
--- a/web/thdProject/apps/backend/modules/film/actions/actions.class.php	Wed Apr 14 18:13:17 2010 +0200
+++ b/web/thdProject/apps/backend/modules/film/actions/actions.class.php	Wed Apr 14 18:20:32 2010 +0200
@@ -23,7 +23,7 @@
         
         // reset sony engine
         $dispatcher = sfContext::getInstance()->getEventDispatcher();
-        $dispatcher->notify(new sfEvent("", 'iri_sonyengine.reset', array('retrain' => true)));
+        $dispatcher->notify(new sfEvent($this, 'iri_sonyengine.reset', array('retrain' => true)));
 		
 		
 		$films_array = array();
--- a/web/thdProject/apps/frontend/modules/search/actions/viewSearchListAction.class.php	Wed Apr 14 18:13:17 2010 +0200
+++ b/web/thdProject/apps/frontend/modules/search/actions/viewSearchListAction.class.php	Wed Apr 14 18:20:32 2010 +0200
@@ -13,15 +13,33 @@
     $this->indexNbItems = 2;
     $this->videoPath = sfConfig::get('app_player_videoPath');
     
-    $query = Doctrine_Query::create()
+    /*$query = Doctrine_Query::create()
       ->from('ThdFilm F')
       ->leftJoin('F.images I ')
       ->leftJoin('F.videos V')
       //->where("cu.code='{$culture}' AND mo.code='{$module}' AND ms.code='{$section}'")
       ->orderBy('F.id DESC')
-      ->limit(0,10);
-    $this->searchFilms = $query->execute();
-    
+      ->limit(0,10);*/
+
+    $solr = uvmcSolrServicesManager::getInstance()->getService();
+    $response = $solr->search($this->text, $this->pageIndex * $this->pageNbItems, $this->pageNbItems);
+
+    $results = unserialize($response->getRawResponse());              
+
+    $primaryKeys = array();
+    foreach($results['response']['docs'] as $doc)
+    {
+      $primaryKeys[] = $doc['id'];
+    }
+
+    if(!empty($primaryKeys))
+    {
+      $this->searchFilms = Doctrine::getTable('ThdFilm')->findByScoredId($primaryKeys);       
+    }
+    else
+    {
+      $this->searchFilms = array();
+    }
     
     return sfView::SUCCESS;
   }