That looks like you add one field with one document and other with
another:
--------------------------------------------------
// Try to set the identifier and the page url into Lucene.
try
{
    // Set page title as text.
    Lucene::setLuceneContent( 'url', PAGE_QUERY_STRING .
"/{$arrPageData['page']['identifier']}" );
 
// at this point setLuceneContent() creates document with one text field
'url' and adds it to the index.

 
    // Set page identifier as a keyword.
    Lucene::setLuceneContent( 'identifier',
$arrPageData['page']['identifier'], 'keyword' );
 
// at this point setLuceneContent() creates another document with one
keyword field 'identifier' and adds it to the index.
}
catch ( Exception $objError )
{
    throw new Exception( "Can't index this content
({$objError->getMessage()})" );
}
-------------------------------------------------
 
 
So you never get document with both fields presented.
 
 
PS If I understood you correctly, you extended Zend_Search_Lucene class
to get your own class Lucene.
I would like to suggest to use agregation instead of extending (store
index object at some class property). 
 
 
With best regards,
   Alexander Veremyev.
 


________________________________

        From: Juan Felipe Alvarez Saldarriaga
[mailto:[EMAIL PROTECTED] 
        Sent: Tuesday, July 31, 2007 2:30 AM
        To: Alexander Veremyev; fw-general@lists.zend.com
        Subject: RE: [fw-general] Zend_Search_Lucene::find() Exception
        
        
        Yes, look, I create a class name "Lucene" who is extended to
Zend_Search_Lucene, so this is the action where I try to make the
"find", it's not done yet, but thes is the base code:
         
        public function searchAction()
        {
            // Load Lucene lib.
            $objLucene = new Lucene( LUCENE_INDEX_PATH );
         
            // Open Lucene index file and get the Lucene Proxy object
from the return.
            $objLuceneIndex = $objLucene->open( LUCENE_INDEX_PATH );
         
            // Try to find this text in the Lucene index file.
            $objLuceneQueryHits = $objLuceneIndex->find(
$this->getRequest()->getPost( 'text' ) );
         
            // Loop hits and create a common structure to show this data
into the view.
            foreach ( $objLuceneQueryHits AS $objLuceneHit )
            {
                // Get Lucene Document object to retrieve data.
                $objLuceneDocument = $objLuceneHit->getDocument();
         
                echo "url: " . $objLuceneDocument->getField( 'url' ) . "
-- " . $objLuceneDocument->getFieldValue( 'url' );
                echo "identifier: " . $objLuceneDocument->getField(
'identifier' ) . " -- " . $objLuceneDocument->getFieldValue(
'identifier' );
                echo "title: " . $objLuceneDocument->getField( 'title' )
. " -- " . $objLuceneDocument->getFieldValue( 'title' );
                echo "content: " . $objLuceneDocument->getField(
'content' ) . " -- " . $objLuceneDocument->getFieldValue( 'content' ) .
"<hr>";
            }
         
        exit();
         
        }
         
        And when I'm adding content to the index I'm just doing like the
ZFW manual example, but I create a method in my "Lucene" class to set a
field with his content as a php switch:
         
         /**
          * Function to set content into Lucene index.
          *
          * @param string $strName Name of the current element to be
indexed.
          * @param string $strContent Content to be indexed by Lucene.
          * @param string $strType Lucene field types, text, keyword,
unstored.
          * @return void
          *
          * NOTE: More info at
http://framework.zend.com/manual/en/zend.search.lucene.html.
          */
         public function setLuceneContent( $strName, $strContent,
$strType = "text" )
         {
          // Try to open the Lucene index file.
          try
          {
           // Load Lucene index file.
           $objLuceneProxy = self::open( LUCENE_INDEX_PATH );
          }
          catch ( Exception $objError )
          {
           throw new Exception( "Can't open the Lucene index file
({$objError->getMessage()})" ); 
          }
         
          // Get Lucene index document.
          $objLuceneDocument = new Zend_Search_Lucene_Document();
         
          // Validate if we really have something to be indexed by
Lucene.
          if ( false !== empty( $strContent ) )
          {
           throw new Exception( "Content to be indexed by Lucene can't
be empty." );
          }
         
          // If the name is empty, ergggghhh.... ERROR!
          if ( false !== empty( $strName ) )
          {
           throw new Exception( "There's not name for the current
element to be indexed." );
          }
         
          // Start indexed using a Lucene field type.
          switch ( $strType )
          {
           case "text":
            // Add "Text" field to the Lucene index content.
            $objLuceneDocument->addField(
Zend_Search_Lucene_Field::Text( $strName, htmlentities( strip_tags(
$strContent ) ) ) );
         
            break;
         
           case "keyword":
            // Add "Keyword" field to the Lucene index content.
            $objLuceneDocument->addField(
Zend_Search_Lucene_Field::Keyword( $strName, htmlentities( strip_tags(
$strContent ) ) ) );
         
            break;
         
           case "unstored":
            // Add "UnStored" field to the Lucene index content.
            $objLuceneDocument->addField(
Zend_Search_Lucene_Field::UnStored( $strName, htmlentities( strip_tags(
$strContent ) ) ) );
         
            break;
         
           case "binary":
            // Add "UnStored" field to the Lucene index content.
            $objLuceneDocument->addField(
Zend_Search_Lucene_Field::Binary( $strName, htmlentities( strip_tags(
$strContent ) ) ) );
         
            break;
         
           case "unindexed":
            // Add "UnStored" field to the Lucene index content.
            $objLuceneDocument->addField(
Zend_Search_Lucene_Field::UnIndexed( $strName, htmlentities( strip_tags(
$strContent ) ) ) );
         
            break;   
         
           default:
            // Add "Text" field to the Lucene index content.
            $objLuceneDocument->addField(
Zend_Search_Lucene_Field::Text( $strName, htmlentities( strip_tags(
$strContent ) ) ) );
         
            break;
          }
         
          // Try to add fields to the current Lucene document.
          try
          {
           // Add current Lucene field to the Lucebe Document.
           $objLuceneProxy->addDocument( $objLuceneDocument );
          }
          catch ( Exception $objError )
          {
           throw new Exception( "Can't add this field ({$strType}) to
the Lucene index file ({$objError->getMessage()})" );
          }
         }
         
        So when I want to add data to the Lucene index I just make:
         
        // Try to set the identifier and the page url into Lucene.
        try
        {
            // Set page title as text.
            Lucene::setLuceneContent( 'url', PAGE_QUERY_STRING .
"/{$arrPageData['page']['identifier']}" );
         
            // Set page identifier as a keyword.
            Lucene::setLuceneContent( 'identifier',
$arrPageData['page']['identifier'], 'keyword' );
        }
        catch ( Exception $objError )
        {
            throw new Exception( "Can't index this content
({$objError->getMessage()})" );
        }
         
        I really dont know what's the problem, thx for any help.

________________________________

        From: Alexander Veremyev [mailto:[EMAIL PROTECTED] 
        Sent: Lunes, 30 de Julio de 2007 04:51 p.m.
        To: Juan Felipe Alvarez Saldarriaga; fw-general@lists.zend.com
        Subject: RE: [fw-general] Zend_Search_Lucene::find() Exception
        
        
        Hi Juan,
         
        Could you give an example of your code?
         
        With best regards,
           Alexander Veremyev.


________________________________

                From: Juan Felipe Alvarez Saldarriaga
[mailto:[EMAIL PROTECTED] 
                Sent: Tuesday, July 31, 2007 1:05 AM
                To: fw-general@lists.zend.com
                Subject: [fw-general] Zend_Search_Lucene::find()
Exception
                
                
                :)
                 
                Im trying to retrieve data from my index, but when I try
to do an echo from one of the hits I always get that the field is not
found in the document, in my case I'm adding four fields, url -> text,
identifier -> keyword, content -> unstored and title -> text, but when I
print the hits object I see that the fields are there:
                 
                ... 
        
[_fields:private] => Array
                                                                (
                                                                    [0]
=> Zend_Search_Lucene_Index_FieldInfo Object
        
(
        
[name] => url
        
[isIndexed] => 1
        
[number] => 0
        
[storeTermVector] => 0
        
)
                
                                                                    [1]
=> Zend_Search_Lucene_Index_FieldInfo Object
        
(
        
[name] => identifier
        
[isIndexed] => 1
        
[number] => 1
        
[storeTermVector] => 0
        
)
                
                                                                    [2]
=> Zend_Search_Lucene_Index_FieldInfo Object
        
(
        
[name] => content
        
[isIndexed] => 1
        
[number] => 2
        
[storeTermVector] => 0
        
)
                
                                                                    [3]
=> Zend_Search_Lucene_Index_FieldInfo Object
        
(
        
[name] => title
        
[isIndexed] => 1
        
[number] => 3
        
[storeTermVector] => 0
        
)
                
                                                                )
                ...
                 
                This is waht I got in the folder where I'm storing the
Lucene index:
                 
                -rw-r--r-- 1 www-data www-data 670 Jul 30 20:56 _d.cfs
                -rw-r--r-- 1 www-data www-data 107 Jul 30 20:56 _d.sti
                -rw-r--r-- 1 www-data www-data   4 Jul 30 20:44
deletable
                -rw-r--r-- 1 www-data www-data   0 Jul 30 20:58
index.lock
                -rw-r--r-- 1 www-data www-data   0 Jul 30 20:56
index.optimization.lock
                -rw-r--r-- 1 www-data www-data  27 Jul 30 20:56 segments
                 
                Any help ?

________________________________

                This message contains confidential information and is
intended only for the individual named. If you are not the named
addressee you should not disseminate, distribute or copy this e-mail.
Please notify the sender immediately by e-mail if you have received this
e-mail by mistake and delete this e-mail from your system. E-mail
transmission cannot be guaranteed to be secure or error-free as
information could be intercepted, corrupted, lost, destroyed, arrive
late or incomplete, or contain viruses. The sender therefore does not
accept liability for any errors or omissions in the contents of this
message, which arise as a result of e-mail transmission. If verification
is required please request a hard-copy version.
                


________________________________

        This message contains confidential information and is intended
only for the individual named. If you are not the named addressee you
should not disseminate, distribute or copy this e-mail. Please notify
the sender immediately by e-mail if you have received this e-mail by
mistake and delete this e-mail from your system. E-mail transmission
cannot be guaranteed to be secure or error-free as information could be
intercepted, corrupted, lost, destroyed, arrive late or incomplete, or
contain viruses. The sender therefore does not accept liability for any
errors or omissions in the contents of this message, which arise as a
result of e-mail transmission. If verification is required please
request a hard-copy version.
        

Reply via email to