To participate you must create an account on apostrophenow.org. If you have already done so, click Login.

Show
Ignore:
Timestamp:
09/01/10 11:59:43 (21 months ago)
Author:
wjohnald
Message:

this commit resolves tickets: #144 and #347

Location:
plugins/apostrophePlugin/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • plugins/apostrophePlugin/trunk

  • plugins/apostrophePlugin/trunk/lib/toolkit/aZendSearch.class.php

    r2030 r2107  
    252252  // use unStoredFields. For things that need not be indexed at all, like summaries, use unIndexedFields 
    253253 
    254   static public function updateLuceneIndex(Doctrine_Record $object, $unStoredFields = array(), $culture = null, $unIndexedFields = array(), $storedAndIndexedFields = array()) 
     254  static public function updateLuceneIndex(Doctrine_Record $object, $fields = array(), $culture = null, $storedFields = array(), $boostsByField = array()) 
    255255  { 
    256256    self::deleteFromLuceneIndex($object, $culture); 
     
    264264      $doc->addField(Zend_Search_Lucene_Field::Keyword('culture', $culture, 'UTF-8')); 
    265265    } 
    266     // index the UnStored fields 
    267     foreach ($unStoredFields as $key => $value) 
     266    // index the search fields 
     267    foreach ($fields as $key => $value) 
    268268    { 
    269269      // Ugh: UTF8 Lucene is case sensitive work around this 
     
    276276        $value = strtolower($value); 
    277277      } 
    278       $doc->addField(Zend_Search_Lucene_Field::UnStored($key, $value, 'UTF-8')); 
     278       
     279      $field = Zend_Search_Lucene_Field::UnStored($key, $value, 'UTF-8'); 
     280      if (isset($boostsByField[$key])) 
     281      { 
     282        $field->boost = $boostsByField[$key]; 
     283      } 
     284      $doc->addField($field); 
    279285    } 
    280286 
    281287    // store the data fields (a big performance win over hydrating things with Doctrine) 
    282     foreach ($unIndexedFields as $key => $value) 
     288    foreach ($storedFields as $key => $value) 
    283289    { 
    284290      $doc->addField(Zend_Search_Lucene_Field::UnIndexed($key, $value, 'UTF-8')); 
    285     } 
    286  
    287     // index and store the storedAndIndexed fields 
    288     foreach ($storedAndIndexedFields as $key => $value) 
    289     { 
    290       // Ugh: UTF8 Lucene is case sensitive work around this 
    291       if (function_exists('mb_strtolower')) 
    292       { 
    293         $value = mb_strtolower($value); 
    294       } 
    295       else 
    296       { 
    297         $value = strtolower($value); 
    298       } 
    299       $doc->addField(Zend_Search_Lucene_Field::Text($key, $value, 'UTF-8')); 
    300291    } 
    301292    
     
    304295    $index->commit(); 
    305296  } 
    306  
     297   
    307298  // This does a clean job of saving the object in both doctrine and zend 
    308299  // without a lot of duplicated code, reducing the potential for