harry
harry

Reputation: 1522

Cannot retrieve value from the Zend_Search_Lucene index

$index = Zend_Search_Lucene::create($indexpath);
$doc = Zend_Search_Lucene_Document_Html::loadHTMLFile ($targeturl);
$title = $doc->title;
$body = $doc->body;
$doc->addField(Zend_Search_Lucene_Field::Text('title', $title));
$doc->addField(Zend_Search_Lucene_Field::unStored('body', $body));
$doc->addField(Zend_Search_Lucene_Field::unIndexed('url', $targeturl));
$index->addDocument($doc);
$index->commit();

This is how I tried to create an index with zend. This is done from an action named as crawlerAction().

I tried to fetch the data from another action named searchresultsAction();

$index = Zend_Search_Lucene::open($indexpath);
$hits =  $index->find($query);
foreach ($hits as $hit) 
{                   
    echo $hit->url;
    echo $hit->title; 
    echo $hit->body;
}

where, $query is the search string.

I'm not getting any output and I'm getting $hits as an empty array. I'm not sure if I have done any mistakes in the code so far. This is the first time I'm doing the search with zend. Can any one point out what went wrong?

Upvotes: 0

Views: 89

Answers (1)

Mark Leighton Fisher
Mark Leighton Fisher

Reputation: 5693

I would look at the index with Luke to see whether my indexing operation completed successfully.

Upvotes: 2

Related Questions