Author: david
Date: Thu Feb 9 21:01:53 2012
New Revision: 10836
Log:
Successfull update of small subset of index fields
Modified:
trunk/lib/QubitSearchPdo.class.php
Modified: trunk/lib/QubitSearchPdo.class.php
==============================================================================
--- trunk/lib/QubitSearchPdo.class.php Thu Feb 9 17:18:33 2012 (r10835)
+++ trunk/lib/QubitSearchPdo.class.php Thu Feb 9 21:01:53 2012 (r10836)
@@ -19,6 +19,9 @@
class QubitSearchPdo extends QubitSearch
{
+ protected static
+ $collectionRoot;
+
public function qubitPopulate($options)
{
if (self::getInstance() instanceof qtElasticSearchPlugin)
@@ -41,7 +44,7 @@
}
else
{
- $this->optimize();
+ //$this->optimize();
}
// set buffering and updates to be batched for better performance
@@ -102,18 +105,20 @@
$offset = intval($ioOffset);
}
+ // Temp limit
+ $limit = 10000;
+
// Get info objects (with offset)
$sql = 'SELECT io.*, i18n.*, slug.slug FROM
'.QubitInformationObject::TABLE_NAME.' io';
$sql .= ' JOIN '.QubitInformationObjectI18n::TABLE_NAME.' i18n';
$sql .= ' ON io.id = i18n.id';
$sql .= ' JOIN '.QubitSlug::TABLE_NAME.' slug';
$sql .= ' ON io.id = slug.object_id';
- $sql .= ' LIMIT :offset, :limit';
+ $sql .= ' ORDER BY io.lft';
+ $sql .= ' LIMIT '.$offset.', '.$limit;
$statement = $conn->prepare($sql);
- if (!$statement->execute(array(
- ':offset' => $offset,
- ':limit' => $rowcount))
+ if (!$statement->execute())
{
throw new sfException('Select failed');
}
@@ -125,11 +130,11 @@
// Loop through results, and add to search index
$i = 0;
- while ($resource = $statemtent->fetch(PDO::FETCH_OBJ))
+ while ($resource = $statement->fetch(PDO::FETCH_OBJ))
{
self::addInformationObjectIndex($resource, $resource->culture,
$options);
- $this->getLogger()->log('"'.$row[QubitInformationObjectI18n::TITLE].'"
inserted ('.round(microtime(true) - $start, 2).'s) ('.($i + $offset +
1).'/'.$rowcount.')', $this->getName());
+ $this->getLogger()->log('"'.$resource->title.'" inserted
('.round(microtime(true) - $start, 2).'s) ('.($i + $offset +
1).'/'.$rowcount.')', $this->getName());
$i++;
}
@@ -161,32 +166,29 @@
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('parent_id',
$resource->parent_id));
$doc->addField(Zend_Search_Lucene_Field::Keyword('parent',
$resource->parent->slug));
- // Get collection root
- $sql = 'SELECT
- root.id,
- slug,
- title,
- culture
- FROM '.QubitInformationObject::TABLE_NAME.' node,
- JOIN '.QubitInformationObjectI18n.' i18n
- ON node.id = i18n.id
- JOIN '.QubitSlug::TABLE_NAME.' slug
- ON node.id = slug.id
- WHERE node.lft < ? AND node.rgt > ?
- ORDER BY node.lft
- LIMIT 1';
- $statement = $conn->prepare($sql);
- if ($statement->execute(array($resource->lft, $resource->rgt))
+ // Collection root
+ if (QubitInformationObject::ROOT_ID == $resource->parent_id &&
+ (!isset(self::$collectionRoot->id) || self::$collectionRoot->id !=
$resource->id))
{
- $collectionRoot = $statement->fetch(PDO::FETCH_OBJ);
+ self::$collectionRoot = $resource;
+ }
+ if (isset(self::$collectionRoot))
+ {
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('collectionRootId',
$collectionRoot->id));
$doc->addField(Zend_Search_Lucene_Field::Keyword('collectionRootSlug',
$collectionRoot->slug));
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('collectionRootTitle',
$collectionRoot->title));
}
+ else
+ {
+ throw new sfException('No collection root for "'.$resource->title.'"');
+ }
// Digital object information
- if ($digitalObject = $resource->getDigitalObject())
+
+ return;
+
+ if ($resource->getDigitalObject())
{
$doc->addField(Zend_Search_Lucene_Field::Keyword('hasDigitalObject',
'true'));
--
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.