Introducción a Zend Framework

 Aprendiendo Zend Framework


 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.5. Searching

    Searching is performed by using the find() method:

    Ejemplo 10.6. Searching through the index

    $hits $index->find($query);

    foreach (
    $hits as $hit) {
    printf("%d %f %s\n"$hit->id$hit->score$hit->title);

    This example demonstrates the usage of two special search hit properties - id and score.

    id is an internal document identifier used within a Lucene index. It may be used for a variety of operations, including deleting a document from the index:

    Ejemplo 10.7. Deleting an Indexed Document


    Or retrieving the document from the index:

    Ejemplo 10.8. Retrieving an Indexed Document

    $doc $index->getDocument($id);

    [Nota] Internal Document Identifiers

    Important note! Internal document identifiers may be changed by index optimization or the auto-optimization process, but it's never changed within a single script's execution unless the addDocument() (which may involve an auto-optimization procedure) or optimize() methods are called.

    The score field is a hit score. Search results are ordered by score by default (best results returned first).

    It's also possible to order result sets by specific field values. See the Zend_Search_Lucene documentation for more details about this possibility.

    The example also demonstrates an ability to access stored fields (e.g., $hit->title). At the first access to any hit property other than id or score, document stored fields are loaded, and the corresponding field value is returned.

    This causes an ambiguity for documents having their own id or score fields; as a result, it's not recommended to use these field names within stored documents. Nevertheless, they still can be accessed via the getDocument() method:

    Ejemplo 10.9. Accessing the original document's "id" and "score" fields

    $id    $hit->getDocument()->id;
    $score $hit->getDocument()->score;

    digg delicious meneame google twitter technorati facebook