Author: david
Date: Fri Feb 17 15:58:06 2012
New Revision: 10932
Log:
Use ZSL Analyzer that tokenizes numbers. Get date, creator and creator history
search and search results working
Modified:
trunk/apps/qubit/modules/search/templates/_searchResults.php
trunk/lib/QubitSearch.class.php
trunk/lib/QubitSearchPdo.class.php
Modified: trunk/apps/qubit/modules/search/templates/_searchResults.php
==============================================================================
--- trunk/apps/qubit/modules/search/templates/_searchResults.php Fri Feb
17 00:03:07 2012 (r10931)
+++ trunk/apps/qubit/modules/search/templates/_searchResults.php Fri Feb
17 15:58:06 2012 (r10932)
@@ -56,8 +56,18 @@
</div>
<?php endif; ?>
- <?php if ($doc->creators): ?>
- <?php echo render_show(__('Creator(s)'), render_value($doc->creators))
?>
+ <?php $creators = unserialize($doc->creatorLinks) ?>
+ <?php if (0 < count($creators)): ?>
+ <div class="field">
+ <h3><?php echo __('Creator(s)') ?></h3>
+ <div>
+ <ul>
+ <?php foreach ($creators as $item): ?>
+ <li><?php echo link_to(render_title($item['name']),
array('slug' => $item['slug'], 'module' => 'actor')) ?></li>
+ <?php endforeach; ?>
+ </ul>
+ </div>
+ </div>
<?php endif; ?>
<?php if ($doc->levelOfDescription): ?>
Modified: trunk/lib/QubitSearch.class.php
==============================================================================
--- trunk/lib/QubitSearch.class.php Fri Feb 17 00:03:07 2012 (r10931)
+++ trunk/lib/QubitSearch.class.php Fri Feb 17 15:58:06 2012 (r10932)
@@ -82,6 +82,7 @@
$this->setEngine(new
xfLuceneEngine(sfConfig::get('sf_data_dir').'/index'));
$this->getEngine()->open();
Zend_Search_Lucene_Search_QueryParser::setDefaultOperator(Zend_Search_Lucene_Search_QueryParser::B_AND);
+ Zend_Search_Lucene_Analysis_Analyzer::setDefault(new
Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum_CaseInsensitive());
}
/**
Modified: trunk/lib/QubitSearchPdo.class.php
==============================================================================
--- trunk/lib/QubitSearchPdo.class.php Fri Feb 17 00:03:07 2012 (r10931)
+++ trunk/lib/QubitSearchPdo.class.php Fri Feb 17 15:58:06 2012 (r10932)
@@ -488,6 +488,7 @@
$startDates = array();
$endDates = array();
$creators = array();
+ $creatorLinks = array();
$histories = array();
if (!isset(self::$creationEventStatement))
@@ -496,6 +497,8 @@
event.id,
event.start_date,
event.end_date,
+ event.actor_id,
+ act_slug.slug,
act_i18n.authorized_form_of_name,
act_i18n.history,
i18n.date';
@@ -504,6 +507,8 @@
ON event.id = i18n.id';
$sql .= ' LEFT JOIN '.QubitActorI18n::TABLE_NAME.' act_i18n
ON event.actor_id = act_i18n.id';
+ $sql .= ' LEFT JOIN '.QubitSlug::TABLE_NAME.' act_slug
+ ON event.actor_id = act_slug.object_id';
$sql .= ' WHERE event.information_object_id = ?
AND event.type_id = ?
AND i18n.culture = ?
@@ -527,22 +532,28 @@
if (isset($item->start_date))
{
- $startDates[] = $item->start_date;
+ $date = new DateTime($item->start_date);
+ $startDates[] = $date->format('Ymd');
}
if (isset($item->end_date))
{
- $endDates[] = $item->end_date;
+ $date = new DateTime($item->end_date);
+ $endDates[] = $date->format('Ymd');
}
- if (isset($item->authorized_form_of_name))
+ if (isset($item->actor_id))
{
- $creators[] = $item->authorized_form_of_name;
- }
+ $creatorNames[] = $item->authorized_form_of_name;
- if (isset($item->history))
- {
- $histories[] = $item->history;
+ $creatorLinks[] = array(
+ 'name' => $item->authorized_form_of_name,
+ 'slug' => $item->slug);
+
+ if (isset($item->history))
+ {
+ $histories[] = $item->history;
+ }
}
}
@@ -551,10 +562,12 @@
$doc->addField(Zend_Search_Lucene_Field::Unstored('endDate', implode(' ',
$endDates)));
// CREATORS
- $creatorField = Zend_Search_Lucene_Field::Keyword('creators', implode(';
', $creators));
+ $creatorField = Zend_Search_Lucene_Field::Unstored('creators', implode('
', $creatorNames));
$creatorField->boost = 8; // Boost the relevance
$doc->addField($creatorField);
+ $doc->addField(Zend_Search_Lucene_Field::UnIndexed('creatorLinks',
serialize($creatorLinks)));
+
$doc->addField(Zend_Search_Lucene_Field::Unstored('creatorHistory',
implode(' ', $histories)));
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.