I'm having some trouble using Zend_Search_Lucene.  I've logged the 
documents (see below) in the index and it looks like they were created 
correctly.  But I don't get any results when I try to search the index.  
Any help would be greatly appreciated.



// Creating the index....

$index = Zend_Search_Lucene::create($config->search_lucene->path);

$item_table = new Item();

$rows = $item_table->fetchAll();

foreach($rows as $row)

{

   $doc = new Zend_Search_Lucene_Document();

   $doc->addField(Zend_Search_Lucene_Field::UnIndexed("item_id", 
$row->id));

   $doc->addField(Zend_Search_Lucene_Field::Text("headline", 
$row->headline));

   $index->addDocument($doc);

}



// search...

$config = Zend_Registry::get('config');

$index = Zend_Search_Lucene::open($config->search_lucene->path);

$hits = $index->find('acura');  // no results???



// Logged all the documents in the index...

for ($count = 0; $count < $index->count(); $count++)

{

      $itemsHit[] = $index->getDocument($count);

      $logger->info(print_r($index->getDocument($count), true));

}



// Log output

Zend_Search_Lucene_Document Object

(

   [_fields:protected] => Array

       (

           [item_id] => Zend_Search_Lucene_Field Object

               (

                   [name] => item_id

                   [value] => 1

                   [isStored] => 1

                   [isIndexed] => 0

                   [isTokenized] => 0

                   [isBinary] =>

                   [storeTermVector] =>

                   [boost] => 1

                   [encoding] => UTF-8

               )

           [headline] => Zend_Search_Lucene_Field Object

               (

                   [name] => headline

                   [value] => 2003 Acura RL

                   [isStored] => 1

                   [isIndexed] => 1

                   [isTokenized] => 1

                   [isBinary] =>

                   [storeTermVector] =>

                   [boost] => 1

                   [encoding] => UTF-8

               )

       )



   [boost] => 1

)



Zend_Search_Lucene_Document Object

(

   [_fields:protected] => Array

       (

           [item_id] => Zend_Search_Lucene_Field Object

               (

                   [name] => item_id

                   [value] => 2

                   [isStored] => 1

                   [isIndexed] => 0

                   [isTokenized] => 0

                   [isBinary] =>

                   [storeTermVector] =>

                   [boost] => 1

                   [encoding] => UTF-8

               )

           [headline] => Zend_Search_Lucene_Field Object

               (

                   [name] => headline

                   [value] => 2005 Nissan 350z

                   [isStored] => 1

                   [isIndexed] => 1

                   [isTokenized] => 1

                   [isBinary] =>

                   [storeTermVector] =>

                   [boost] => 1

                   [encoding] => UTF-8

               )

       )



   [boost] => 1

)














      
____________________________________________________________________________________
Tonight's top picks. What will you watch tonight? Preview the hottest shows on 
Yahoo! TV.
http://tv.yahoo.com/ 

Reply via email to