Changeset 1312


Ignore:
Timestamp:
Sep 2, 2010, 1:22:22 AM (11 years ago)
Author:
teymour
Message:

Indexation possible, reste un pb de gestion de fichier à regler

Location:
cpc/trunk/project
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • cpc/trunk/project/config/doctrine/schema.yml

    r1250 r1312  
    177177    Taggable: ~
    178178    Solrable:
    179       description: [Parlementaire, Personnalite, Intervention]
     179      description: [Parlementaire, Personnalite, intervention]
    180180      moretags: [Parlementaire, Personnalite, type]
    181181      devaluate_if_wordcount_under: 100
  • cpc/trunk/project/lib/model/solr/SolrListener.php

    r1311 r1312  
    3535
    3636  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";
    3841      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";
    4045      return ;
     46    }
    4147    foreach(file(self::getFileCommands().'.lock') as $line) {
    4248      if (preg_match('/\] (UPDATE|REMOVE): (.+)/', $line, $matches)) {
     49        echo $matches[1]." ".$matches[2]."\n";
     50        $obj = json_decode($matches[2]);
    4351        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);
    4953        }else{
    50           $this->solr->deleteById($matches[2].'/'.$matches[3]);
     54          $this->solr->deleteById($obj->id);
    5155        }
    5256      }
     
    5660
    5761
    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) )
    6165      return $this->solr->commit();
    6266    return false;
     
    6569  public function updateLuceneRecord($obj)
    6670  {
    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();
    7585  }
    7686
  • cpc/trunk/project/test/unit/solrableTest.php

    r1311 r1312  
    3838$s->updateFromCommands();
    3939$a = $s->search("salut id:$id");
     40print_r($a);
    4041$t->is($a['response']['docs'][0]['id'], $id, "L'intervention retournée sur des mots reindexés");
    4142
Note: See TracChangeset for help on using the changeset viewer.