Here it is.  Greatly appreciate your kind help.

---------------------------------

<?php
     require_once 'Zend/Search/Lucene.php';
     require_once 'Zend/Search/Lucene/Document/Html.php';

     if(is_dir("/local/clien/www/html_index/an_index") == 1){
     $index
=Zend_Search_Lucene::open('/local/clien/www/html_index/an_index');
     echo "opening index...<br>";
     }
     else {
     //Create a new index
     $index
=Zend_Search_Lucene::create('/local/clien/www/html_index/an_index');
     echo "creating index...<br>";
     }

     $filename="AFile";
     $doc = Zend_Search_Lucene_Document_Html::loadHTMLFile($filename);
     $doc->addField(Zend_Search_Lucene_Field::UnIndexed('url', $filename));
     $index->addDocument($doc);
?>


----------------------

Serkys wrote:
> 
> Show me full code of creating index, please
> 
> 
> Jean L wrote:
>> 
>> Thanks for the reply.
>> 
>> I change it to "UnIndexed" field, however, the same error message is
>> still there....
>> 
>> Jean
>> 
>> 
>> 
>> Serkys wrote:
>>> 
>>> I think, URL better stored in "UnIndexed" fields.
>>> 
>>> 
>>> Jean L wrote:
>>>> 
>>>> Hi all,
>>>> 
>>>> I'm currently having problem with indexing html files using
>>>> Zend_Search_Lucene.  Any help is appreciated.
>>>> 
>>>> So far I can create my index properly.  I add text field "url" to store
>>>> my file name and add that to my doc.  
>>>> 
>>>> Here's the problem:  when I want to show the file name, an error
>>>> message occurs and it reads :
>>>> PHP Fatal error:Uncaught exception 'Zend_Search_Lucene'with message
>>>> 'Field name "url" not found in document.' in
>>>> local/zend/1.7.3/app/library/Zend/Search/Lucene/Document.php:102\nStack
>>>> trace:\n#0
>>>> /local/zend/1.7.3/app/library/Zend/Search/Lucene/Document(116):
>>>> Zend_Search_Lucene_Document->getField('url')#1....(continued)
>>>> 
>>>> The code is following:
>>>> ---------------------------------
>>>> $filename="aFile";
>>>>      $doc = Zend_Search_Lucene_Document_Html::loadHTMLFile($filename);
>>>>      $doc->addField(Zend_Search_Lucene_Field::Text('url', $filename));
>>>>      $index->addDocument($doc);
>>>> ......
>>>> 
>>>> ---------------------------------
>>>> $query=Zend_Search_Lucene_Search_QueryParser::parse($queryStr);
>>>> $hits = $index->find($query);
>>>> foreach ($hits as $hit) {
>>>>                       echo $hit->url."<br>";
>>>>                       echo $hit->title."<br>";
>>>> .....
>>>> 
>>>> Any help is appreciated.
>>>> 
>>>> Jean
>>>> 
>>>> 
>>> 
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Zend_Search_Lucene-field-not-found-tp22153855p22188081.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to