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.4. Indexing

    Indexing is performed by adding a new document to an existing or new index:

    $index->addDocument($doc);

    There are two ways to create document object. The first is to do it manually.

    Ejemplo 10.3. Manual Document Construction

    $doc = new Zend_Search_Lucene_Document();
    $doc->addField(Zend_Search_Lucene_Field::Text('url'$docUrl));
    $doc->addField(Zend_Search_Lucene_Field::Text('title'$docTitle));
    $doc->addField(Zend_Search_Lucene_Field::unStored('contents'$docBody));
    $doc->addField(Zend_Search_Lucene_Field::binary('avatar'$avatarData));

    The second method is to load it from HTML or Microsoft Office 2007 files:

    Ejemplo 10.4. Document loading

    $doc Zend_Search_Lucene_Document_Html::loadHTML($htmlString);
    $doc Zend_Search_Lucene_Document_Docx::loadDocxFile($path);
    $doc Zend_Search_Lucene_Document_Pptx::loadPptFile($path);
    $doc Zend_Search_Lucene_Document_Xlsx::loadXlsxFile($path);

    If a document is loaded from one of the supported formats, it still can be extended manually with new user defined fields.

    10.4.1. Indexing Policy

    You should define indexing policy within your application architectural design.

    You may need an on-demand indexing configuration (something like OLTP system). In such systems, you usually add one document per user request. As such, the MaxBufferedDocs option will not affect the system. On the other hand, MaxMergeDocs is really helpful as it allows you to limit maximum script execution time. MergeFactor should be set to a value that keeps balance between the average indexing time (it's also affected by average auto-optimization time) and search performance (index optimization level is dependent on the number of segments).

    If you will be primarily performing batch index updates, your configuration should use a MaxBufferedDocs option set to the maximum value supported by the available amount of memory. MaxMergeDocs and MergeFactor have to be set to values reducing auto-optimization involvement as much as possible [5]. Full index optimization should be applied after indexing.

    Ejemplo 10.5. Index optimization

    $index->optimize();

    In some configurations, it's more effective to serialize index updates by organizing update requests into a queue and processing several update requests in a single script execution. This reduces index opening overhead, and allows utilizing index document buffering.



    [5] An additional limit is the maximum file handlers supported by the operation system for concurrent open operations

    digg delicious meneame google twitter technorati facebook

    Comentarios

    Loading...