Changeset 1312
- Timestamp:
- Sep 2, 2010, 1:22:22 AM (11 years ago)
- Location:
- cpc/trunk/project
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
cpc/trunk/project/config/doctrine/schema.yml
r1250 r1312 177 177 Taggable: ~ 178 178 Solrable: 179 description: [Parlementaire, Personnalite, Intervention]179 description: [Parlementaire, Personnalite, intervention] 180 180 moretags: [Parlementaire, Personnalite, type] 181 181 devaluate_if_wordcount_under: 100 -
cpc/trunk/project/lib/model/solr/SolrListener.php
r1311 r1312 35 35 36 36 public function updateFromCommands() { 37 if (!file_exists(self::getFileCommands().'.lock') && file_exists(self::getFileCommands())) 37 echo "UpdateFromCommands\n"; 38 echo file_exists(self::getFileCommands())."\n"; 39 if (!file_exists(self::getFileCommands().'.lock') && file_exists(self::getFileCommands())) { 40 echo "rename \n"; 38 41 rename(self::getFileCommands(), self::getFileCommands().'.lock'); 39 if (!file_exists(self::getFileCommands().'.lock')) 42 } 43 if (!file_exists(self::getFileCommands().'.lock')) { 44 echo "No lock\n"; 40 45 return ; 46 } 41 47 foreach(file(self::getFileCommands().'.lock') as $line) { 42 48 if (preg_match('/\] (UPDATE|REMOVE): (.+)/', $line, $matches)) { 49 echo $matches[1]." ".$matches[2]."\n"; 50 $obj = json_decode($matches[2]); 43 51 if ($matches[1] == 'UPDATE') { 44 $obj = Doctrine::getTable($matches[2])->find($matches[3]); 45 if ($obj) 46 $this->updateLuceneRecord($obj); 47 else 48 echo $matches[2].'/'.$matches[3]." not found\n"; 52 $this->updateLuceneRecord($obj); 49 53 }else{ 50 $this->solr->deleteById($ matches[2].'/'.$matches[3]);54 $this->solr->deleteById($obj->id); 51 55 } 52 56 } … … 56 60 57 61 58 public function deleteLuceneRecord($ obj)59 { 60 if($this->solr->deleteById($ this->getLuceneObjId($obj)))62 public function deleteLuceneRecord($id) 63 { 64 if($this->solr->deleteById($id) ) 61 65 return $this->solr->commit(); 62 66 return false; … … 65 69 public function updateLuceneRecord($obj) 66 70 { 67 $t = NULL; 68 $obj_options = $obj->getListener()->getOptions(); 69 70 print_r($obj->getOptions()); 71 exit; 72 73 $this->solr->addDocument($document); 74 $this->solr->commit(); 71 $document = new Apache_Solr_Document(); 72 $document->addField('id', $obj->id); 73 $document->addField('object_id', $obj->object_id); 74 $document->addField('object_name', $obj->object_name); 75 if (isset($obj->wordcount)) 76 $document->addField('wordcount', $obj->wordcount); 77 if (isset($obj->title)) 78 $document->addField('title', $obj->title->content, $obj->title->weight); 79 if (isset($obj->description)) 80 $document->addField('description', $obj->description->content, $obj->description->weight); 81 if (isset($obj->date)) 82 $document->addField('date', $obj->date->content, $obj->date->weight); 83 $this->solr->addDocument($document); 84 $this->solr->commit(); 75 85 } 76 86 -
cpc/trunk/project/test/unit/solrableTest.php
r1311 r1312 38 38 $s->updateFromCommands(); 39 39 $a = $s->search("salut id:$id"); 40 print_r($a); 40 41 $t->is($a['response']['docs'][0]['id'], $id, "L'intervention retournée sur des mots reindexés"); 41 42
Note: See TracChangeset
for help on using the changeset viewer.