Programmer's Reference Guide

Unterstützte Abfragen

Seitendarstellung von Suchergebnissen

Wie vorher erwähnt, verwenden die Hit Objekte von Suchergebnissen Lazy Loading für gespeicherte Dokumentfelder. Wenn auf ein gespeichertes Feld zugegriffen wird, wird das komplette Dokument geladen.

Man sollte nicht alle Dokumente empfangen wenn man nur mit einem Teil von Ihnen arbeiten muss. Man sollte durch die Suchergebnisse gehen und die IDs der Dokumente irgendwo speichern (und optional die Bewertung) um die Dokumente vom Index bei der nächsten Ausführung des Skripts zu erhalten.

Beispiel #1 Beispiel für die seitendarstellung von Suchergebnissen

  1. $cacheId = md5($query);
  2.  
  3. if (!$resultSet = $cache->load($cacheId)) {
  4.     $hits = $index->find($query);
  5.     $resultSet = array();
  6.     foreach ($hits as $hit) {
  7.         $resultSetEntry          = array();
  8.         $resultSetEntry['id']    = $hit->id;
  9.         $resultSetEntry['score'] = $hit->score;
  10.  
  11.         $resultSet[] = $resultSetEntry;
  12.     }
  13.  
  14.     $cache->save($resultSet, $cacheId);
  15. }
  16.  
  17. $publishedResultSet = array();
  18. for ($resultId = $startId; $resultId < $endId; $resultId++) {
  19.     $publishedResultSet[$resultId] = array(
  20.         'id'    => $resultSet[$resultId]['id'],
  21.         'score' => $resultSet[$resultId]['score'],
  22.         'doc'   => $index->getDocument($resultSet[$resultId]['id']),
  23.     );
  24. }

Unterstützte Abfragen

Comments

This doesn't make any sense at all. What does this have to do with paginating search results? :-S
Very bad example...undefined variables...no real live context!!!
why encrypt / hash a query string? that first line doesn't make sense
ok ... hindsight being what it is ... you have to cache a search query in order for it to persist over various pages after submitting/passing search values to Paginator

still this documentation is pretty damn convoluted
given that i have successfully implemented the Paginator tool in a straight SQL query (no wildcard WHERE var='%keyword%' conditions) i understand how the Zend_Cache is necessary to persist the keyword over many page loads ... however Paginator isn't referenced once in the above example and i have no idea how to integrate the two ( Paginator and Zend_Cache ). another fail for ZF documentation
ongoing grieve with the zend cache ... if the $_POST values are destroyed when loading pages, how do you make the md5() value persist over page loads when using paginator to page through results of a mysql wildcard search? if i don't have the md5() value on subsequent page loads, how can i access the cached value in zend_cache()? why am i talking to myself? and why am i doing it on the internet?

+ Add A Comment

Please do not report issues via comments; use the ZF Issue Tracker.

If you have a JIRA/Crowd account, we suggest you login first before commenting.

  • BBCode is allowed in the comment markup

  • Select a Version

    Languages Available

    Components

    Search the Manual