Introducción a Zend Framework

 Aprendiendo Zend Framework

Apéndice

 Referencia de Zend Framework


  • Zend_Gdata
  • Zend_Http
  • Zend_InfoCard
  • Zend_Json
  • Zend_Layout
  • Zend_Ldap
  • Zend_Loader
  • Zend_Locale
  • Zend_Log
  • Zend_Mail
  • Zend_Markup
  • Zend_Measure
  • Zend_Memory
  • Zend_Mime
  • Zend_Navigation
  • Zend_Oauth
  • Zend_OpenId
  • Zend_Paginator
  • Zend_Pdf
  • Zend_ProgressBar
  • Zend_Queue
  • Zend_Reflection
  • Zend_Registry
  • Zend_Rest

  • Zend_Search_Lucene
  • Zend_Serializer
  • Zend_Server
  • Zend_Service
  • Zend_Session
  • Zend_Soap
  • Zend_Tag
  • Zend_Test
  • Zend_Text
  • Zend_TimeSync
  • Zend_Tool
  • Zend_Tool_Framework
  • Zend_Tool_Project
  • Zend_Translate
  • Zend_Uri
  • Zend_Validate
  • Zend_Version
  • Zend_View
  • Zend_Wildfire
  • Zend_XmlRpc
  • ZendX_Console_Process_Unix
  • ZendX_JQuery
  • Traducción al 26.9% - Actualizado el 2011-11-16 - Revisión 24249 - Versión ZF 1.11.x

    10.7. Search result pagination

    As mentioned above, search result hit objects use lazy loading for stored document fields. When any stored field is accessed, the complete document is loaded.

    Do not retrieve all documents if you actually need to work only with some portion of them. Go through the search results and store document IDs (and optionally the score) somewhere to retrive documents from the index during the next script execution.

    Ejemplo 10.25. Search result pagination example

    $cacheId md5($query);

    if (!
    $resultSet $cache->load($cacheId)) {
        
    $hits $index->find($query);
        
    $resultSet = array();
        foreach (
    $hits as $hit) {
            
    $resultSetEntry          = array();
            
    $resultSetEntry['id']    = $hit->id;
            
    $resultSetEntry['score'] = $hit->score;

            
    $resultSet[] = $resultSetEntry;
        }

        
    $cache->save($resultSet$cacheId);
    }

    $publishedResultSet = array();
    for (
    $resultId $startId$resultId $endId$resultId++) {
        
    $publishedResultSet[$resultId] = array(
            
    'id'    => $resultSet[$resultId]['id'],
            
    'score' => $resultSet[$resultId]['score'],
            
    'doc'   => $index->getDocument($resultSet[$resultId]['id']),
        );
    }

    digg delicious meneame google twitter technorati facebook

    Comentarios

    Loading...