Author: david
Date: Wed Jul  4 16:14:16 2012
New Revision: 11852

Log:
Boost authority record search terms.  Use raw SQL/PDO query for other names

Modified:
   trunk/lib/QubitSearch.class.php

Modified: trunk/lib/QubitSearch.class.php
==============================================================================
--- trunk/lib/QubitSearch.class.php     Wed Jul  4 14:10:43 2012        (r11851)
+++ trunk/lib/QubitSearch.class.php     Wed Jul  4 16:14:16 2012        (r11852)
@@ -339,9 +339,21 @@
 
       $doc->addField(Zend_Search_Lucene_Field::UnStored('identifier', 
$actor->descriptionIdentifier));
 
-      
$doc->addField(Zend_Search_Lucene_Field::UnStored('authorizedFormOfName', 
$actorI18n->authorizedFormOfName));
-      $doc->addField(Zend_Search_Lucene_Field::UnStored('datesOfExistence', 
$actorI18n->datesOfExistence));
-      $doc->addField(Zend_Search_Lucene_Field::UnStored('history', 
$actorI18n->history));
+      // Boost authorized form of name
+      $field = Zend_Search_Lucene_Field::UnStored('authorizedFormOfName', 
$actorI18n->authorizedFormOfName);
+      $field->boost = 10;
+      $doc->addField($field);
+
+      // Boost dates of existence
+      $field = Zend_Search_Lucene_Field::UnStored('datesOfExistence', 
$actorI18n->datesOfExistence);
+      $field->boost = 5;
+      $doc->addField($field);
+
+      // Boost history
+      $history = Zend_Search_Lucene_Field::UnStored('history', 
$actorI18n->history);
+      $history->boost = 3;
+      $doc->addField($history);
+
       $doc->addField(Zend_Search_Lucene_Field::UnStored('places', 
$actorI18n->places));
       $doc->addField(Zend_Search_Lucene_Field::UnStored('legalStatus', 
$actorI18n->legalStatus));
       $doc->addField(Zend_Search_Lucene_Field::UnStored('functions', 
$actorI18n->functions));
@@ -350,20 +362,34 @@
       $doc->addField(Zend_Search_Lucene_Field::UnStored('generalContext', 
$actorI18n->generalContext));
 
       // Add other forms of name for this culture
-      $criteria = new Criteria;
-      $criteria->addJoin(QubitOtherNameI18n::ID, QubitOtherName::ID);
-      $criteria->add(QubitOtherNameI18n::CULTURE, $actorI18n->culture);
-      $criteria->add(QubitOtherName::OBJECT_ID, $actor->id);
+      if (!isset($otherNameStmt))
+      {
+        $conn = Propel::getConnection();
+        $sql = 'SELECT i18n.name
+           FROM other_name JOIN other_name_i18n i18n ON other_name.id = i18n.id
+           WHERE object_id = ? and culture = ?';
+        $otherNameStmt = $conn->prepare($sql);
+      }
+      $otherNameStmt->execute(array($actor->id, $actorI18n->culture));
 
-      if (0 < count($otherNameI18ns = QubitOtherNameI18n::get($criteria)))
+      $otherNames = array();
+      while ($otherName = $otherNameStmt->fetchColumn())
       {
-        foreach ($otherNameI18ns as $otherNameI18n)
-        {
-          $otherNames[] = $otherNameI18n->name;
-        }
+        $otherNames[] = $otherName;
+      }
 
-        $doc->addField(Zend_Search_Lucene_Field::UnStored('otherFormsOfName', 
implode(' ', $otherNames)));
+      if (0 < count($otherNames))
+      {
+        $field = Zend_Search_Lucene_Field::UnStored('otherFormsOfName', 
implode(' ', $otherNames));
       }
+      else
+      {
+        $field = Zend_Search_Lucene_Field::UnStored('otherFormsOfName', null);
+      }
+
+      // Boost other names
+      $field->boost = 8;
+      $doc->addField($field);
 
       self::getInstance()->getEngine()->getIndex()->addDocument($doc);
     }

-- 
You received this message because you are subscribed to the Google Groups 
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/qubit-commits?hl=en.

Reply via email to