Author: david
Date: Fri Feb 24 13:25:22 2012
New Revision: 10972

Log:
Merge subject and place indexing from QubitSearchPdo

Modified:
   trunk/lib/QubitSearch.class.php
   trunk/lib/QubitSearchPdo.class.php

Modified: trunk/lib/QubitSearch.class.php
==============================================================================
--- trunk/lib/QubitSearch.class.php     Fri Feb 24 13:18:37 2012        (r10971)
+++ trunk/lib/QubitSearch.class.php     Fri Feb 24 13:25:22 2012        (r10972)
@@ -600,21 +600,12 @@
     $doc->addField(Zend_Search_Lucene_Field::Unstored('locationofcopies', 
$informationObject->getLocationOfCopies(array('culture' => $language))));
     
$doc->addField(Zend_Search_Lucene_Field::Unstored('relatedunitsofdescription', 
$informationObject->getRelatedUnitsOfDescription(array('culture' => 
$language))));
 
-    // Subjects
-    $subjectField = Zend_Search_Lucene_Field::Unstored('subject', 
$informationObject->getAccessPointsString(QubitTaxonomy::SUBJECT_ID, 
array('culture' => $language)));
-    // Boost the hit relevance for the subject field
-    $subjectField->boost = 5;
-    $doc->addField($subjectField);
-
-    // Place
-    $placeField = Zend_Search_Lucene_Field::Unstored('place', 
$informationObject->getAccessPointsString(QubitTaxonomy::PLACE_ID, 
array('culture' => $language)));
-    // Boost the hit relevance for the place field
-    $placeField->boost = 3;
-    $doc->addField($placeField);
-
     // NAME ACCESS POINTS
     $doc = self::addNameAccessPoints($doc, $informationObject->id, $language);
 
+    // SUBJECT AND PLACE ACCESS POINTS
+    $doc = self::addSubjectsAndPlaces($doc, $informationObject->id, $language);
+
     // LANGUAGES AND SCRIPTS
     $doc = self::addLanguagesAndScripts($doc, $informationObject->id, 
$language);
 
@@ -799,6 +790,70 @@
     return $doc;
   }
 
+  protected static function addSubjectsAndPlaces($doc, $informationObjectId, 
$culture)
+  {
+    $subject = $places = array();
+
+    if (!isset(self::$statements['subjectsPlaces']))
+    {
+      $sql  = 'SELECT
+                  term.taxonomy_id,
+                  i18n.name';
+      $sql .= ' FROM '.QubitObjectTermRelation::TABLE_NAME.' otr';
+      $sql .= ' JOIN '.QubitTerm::TABLE_NAME.' term 
+                  ON otr.term_id = term.id';
+      $sql .= ' JOIN '.QubitTermI18n::TABLE_NAME.' i18n
+                  ON term.id = i18n.id';
+      $sql .= ' WHERE otr.object_id = ?
+                  AND i18n.culture = ?
+                  AND (term.taxonomy_id = ?
+                    OR term.taxonomy_id = ?)';
+
+      self::$statements['subjectsPlaces'] = self::$conn->prepare($sql);
+    }
+
+    self::$statements['subjectsPlaces']->execute(array(
+      $informationObjectId,
+      $culture,
+      QubitTaxonomy::SUBJECT_ID,
+      QubitTaxonomy::PLACE_ID));
+
+    foreach (self::$statements['subjectsPlaces']->fetchAll(PDO::FETCH_OBJ) as 
$item)
+    {
+      switch ($item->taxonomy_id)
+      {
+        // Subject
+        case QubitTaxonomy::SUBJECT_ID:
+          $subjects[] = $item->name;
+          break;
+
+        // Place
+        case QubitTaxonomy::PLACE_ID:
+          $places[] = $item->name;
+          break;
+
+      }
+
+      if (0 < count($subjects))
+      {
+        $subjectField = Zend_Search_Lucene_Field::Unstored('subject', 
implode(' ', $subjects));
+        // Boost the hit relevance for the subject field
+        $subjectField->boost = 5;
+        $doc->addField($subjectField);
+      }
+
+      if (0 < count($places))
+      {
+        $placeField = Zend_Search_Lucene_Field::Unstored('place', implode(' ', 
$places));
+        // Boost the hit relevance for the place field
+        $placeField->boost = 3;
+        $doc->addField($placeField);
+      }
+    }
+
+    return $doc;
+  }
+
   protected static function addLanguagesAndScripts($doc, $informationObjectId, 
$culture)
   {
     // Get lookup tables

Modified: trunk/lib/QubitSearchPdo.class.php
==============================================================================
--- trunk/lib/QubitSearchPdo.class.php  Fri Feb 24 13:18:37 2012        (r10971)
+++ trunk/lib/QubitSearchPdo.class.php  Fri Feb 24 13:25:22 2012        (r10972)
@@ -418,68 +418,4 @@
       return self::$levelsOfDescription[$id]->getName(array('culture' => 
$culture));
     }
   }
-
-  protected static function addSubjectsAndPlaces($doc, $informationObjectId, 
$culture)
-  {
-    $subject = $places = array();
-
-    if (!isset(self::$statements['subjectsPlaces']))
-    {
-      $sql  = 'SELECT
-                  term.taxonomy_id,
-                  i18n.name';
-      $sql .= ' FROM '.QubitObjectTermRelation::TABLE_NAME.' otr';
-      $sql .= ' JOIN '.QubitTerm::TABLE_NAME.' term 
-                  ON otr.term_id = term.id';
-      $sql .= ' JOIN '.QubitTermI18n::TABLE_NAME.' i18n
-                  ON term.id = i18n.id';
-      $sql .= ' WHERE otr.object_id = ?
-                  AND i18n.culture = ?
-                  AND (term.taxonomy_id = ?
-                    OR term.taxonomy_id = ?)';
-
-      self::$statements['subjectsPlaces'] = self::$conn->prepare($sql);
-    }
-
-    self::$statements['subjectsPlaces']->execute(array(
-      $informationObjectId,
-      $culture,
-      QubitTaxonomy::SUBJECT_ID,
-      QubitTaxonomy::PLACE_ID));
-
-    foreach (self::$statements['subjectsPlaces']->fetchAll(PDO::FETCH_OBJ) as 
$item)
-    {
-      switch ($item->taxonomy_id)
-      {
-        // Subject
-        case QubitTaxonomy::SUBJECT_ID:
-          $subjects[] = $item->name;
-          break;
-
-        // Place
-        case QubitTaxonomy::PLACE_ID:
-          $places[] = $item->name;
-          break;
-
-      }
-
-      if (0 < count($subjects))
-      {
-        $subjectField = Zend_Search_Lucene_Field::Unstored('subject', 
implode(' ', $subjects));
-        // Boost the hit relevance for the subject field
-        $subjectField->boost = 5;
-        $doc->addField($subjectField);
-      }
-
-      if (0 < count($places))
-      {
-        $placeField = Zend_Search_Lucene_Field::Unstored('place', implode(' ', 
$places));
-        // Boost the hit relevance for the place field
-        $placeField->boost = 3;
-        $doc->addField($placeField);
-      }
-    }
-
-    return $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