0
$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?

1 Answer 1

2

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.