Changeset 1541
- Timestamp:
- Oct 2, 2010, 11:57:16 PM (10 years ago)
- Location:
- cpc/trunk/project
- Files:
-
- 3 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
cpc/trunk/project/lib/model/solr/SolrConnector.class.php
r1405 r1541 88 88 for ($i = 0 ; $i < count($results['response']['docs']); $i++) { 89 89 $res = $results['response']['docs'][$i]; 90 $results['response']['docs'][$i]['object'] = Doctrine::getTable($res['object_name'])->find($res['object_id']); 90 if ($res['object_name'] == 'NonObjectPage') { 91 $results['response']['docs'][$i]['object'] = NonObjectPage::find($res['object_id']); 92 }else{ 93 $results['response']['docs'][$i]['object'] = Doctrine::getTable($res['object_name'])->find($res['object_id']); 94 } 91 95 if (!$results['response']['docs'][$i]['object']) 92 96 $unset[] = $i; -
cpc/trunk/project/lib/task/indexSolrTask.class.php
r1456 r1541 21 21 $this->addOption('removeAll', null, sfCommandOption::PARAMETER_OPTIONAL, 'Drop solr database (=no|yes no default)', 'no'); 22 22 $this->addOption('all', null, sfCommandOption::PARAMETER_OPTIONAL, 'Reindex all the database (=no|yes no default)', 'no'); 23 $this->addOption('pages', null, sfCommandOption::PARAMETER_OPTIONAL, 'Index static pages (=no|yes no default)', 'no'); 23 24 24 25 $this->file_conf = sys_get_temp_dir().DIRECTORY_SEPARATOR."reindex_slor.db"; … … 26 27 if (file_exists($this->file_conf)) { 27 28 $this->state = unserialize(file_get_contents($this->file_conf)); 29 } 30 } 31 32 protected function indexNonObjectPages($solr) { 33 $array = NonObjectPage::getElements(); 34 foreach ($array as $k => $v) { 35 $json = new stdClass(); 36 $json->id = 'NonObjectPage/'.$k; 37 $json->object_name = 'NonObjectPage'; 38 $json->object_id = $k; 39 $weight = $v['weight']; 40 if (!$weight) { 41 $weight = 1; 42 } 43 $json->title->content = $v['title']; 44 $json->title->weight = $weight * 1.2; 45 if (isset($a['description'])) { 46 $json->description->content = $v['description']; 47 $json->description->weight = $weight; 48 } 49 $solr->updateLuceneRecord($json); 28 50 } 29 51 } … … 37 59 if ($options['removeAll'] == 'yes') { 38 60 $solr->deleteAll(); 61 } 62 63 if ($options['pages'] == 'yes') { 64 $this->indexNonObjectPages($solr); 65 return ; 39 66 } 40 67
Note: See TracChangeset
for help on using the changeset viewer.