Author: david
Date: Fri Oct 16 12:09:45 2009
New Revision: 3763
Log:
Remove multiple instances of same information object from search results. Fixes
issue #923.
Modified:
trunk/apps/qubit/modules/informationobject/actions/listAction.class.php
Modified:
trunk/apps/qubit/modules/informationobject/actions/listAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/informationobject/actions/listAction.class.php
Fri Oct 16 11:15:48 2009 (r3762)
+++ trunk/apps/qubit/modules/informationobject/actions/listAction.class.php
Fri Oct 16 12:09:45 2009 (r3763)
@@ -127,18 +127,28 @@
}
}
- $this->pager = new QubitSearchPager;
- $this->pager->hits = $search->getEngine()->getIndex()->find($query);
- $this->pager->setPage($request->page);
+ // Do search
+ $results = $search->getEngine()->getIndex()->find($query);
- $ids = array();
- foreach ($this->pager->getResults() as $hit)
+ // Loop through results and get a list of unique ids because orignial
+ // search may return a hit for each culture of info object
+ $uniqueIds = array();
+ foreach ($results as $result)
{
- $ids[] = $hit->getDocument()->id;
+ if (!in_array(($id = $result->getDocument()->id), $uniqueIds))
+ {
+ $uniqueIds[] = $id;
+ }
}
+ // Paginate
+ $this->pager = new QubitSearchPager;
+ $this->pager->hits = $uniqueIds;
+ $this->pager->setPage($request->page);
+
+ // Get ORM objects for display
$criteria = new Criteria;
- $criteria->add(QubitInformationObject::ID, $ids, Criteria::IN);
+ $criteria->add(QubitInformationObject::ID, $this->pager->getResults(),
Criteria::IN);
$this->informationObjects = QubitInformationObject::get($criteria);
}
}
--~--~---------~--~----~------------~-------~--~----~
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.ca/group/qubit-commits?hl=en
-~----------~----~----~----~------~----~------~--~---