Hi Smita,

I think you always want to use a directory path as the $index_path, not a path 
to a filename. If you're simply trying to test whether or not the path has 
already been created, try catching the Zend Exception you're seeing :)

My code only passes in the true argument if I'm in the process of indexing 
documents; don't pass true if you are trying to read from an existing index, 
say at search time.

Best,
mattpaul

-----Original Message-----
From: smita [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, January 03, 2007 11:46 AM
To: [email protected]
Subject: Re: [fw-general] Problems with Zend_Search_Lucene


Hi,
I am having the same issue with opening Zend lucene index path and though
the index does not exist I get this message. I am not sure I understand this
thread. Has the issue been resolved? I am trying this
if(is_dir($index_path))
                $index = new Zend_Search_Lucene($index_path); 
        else 
                $index = new Zend_Search_Lucene($index_path, true); 

And the error I get is
 Fatal error:  Uncaught exception 'Zend_Search_Lucene_Exception' with
message 'failed to open stream: No such file or directory' in
/usr/local/stepup/phplibs/Zend/Search/Lucene/Storage/File/Filesystem.php:63
Please help.
-Smita



Alexander Veremyev wrote:
> 
> Hi Jan,
> 
> Zend_Search_Lucene treats input as a string in current locale encoding.
> 
> Set correct current locale:
> ----------
> setlocale(LC_CTYPE, 'de_DE.UTF8');
> ----------
> 
> or convert data returned by MySQL to current locale.
> 
> $data = iconv('UTF-8', '', $data);
> $doc->addField(Zend_Search_Lucene_Field::Text('contents', $data))
> 
> If you will get notice in your code, use:
> ------------
> $data = iconv('UTF-8', '//TRANSLIT', $data);
> or
> $data = iconv('UTF-8', '//IGNORE', $data);
> ------------
> 
> 
> With best regards,
>     Alexander Veremyev.
> 
> Jan Pieper wrote:
> 
>> Okay, I changed all paths to absolute path and now it does function but
>> now I have the problem that all entries breaks before a german Umlaut
>> (äüöß). The entries are stored in a MySQL database (utf8_unicode_ci).
>> 
>> original: "... Verwaltung, dass ein Paket für mich ..."
>> lucene: "... Verwaltung, dass ein Paket f"
>> 
>> I looked into Zend/Search/Lucene/Field.php in line 61 there is iconv() to
>> convert all utf-8 strings to ansi but I get E_NOTICEs by creating the
>> index. What can I do to have an index with german Umlauts?
>> 
>> -- Jan
>> 
>> -------- Original-Nachricht --------
>> Datum: Fri, 13 Oct 2006 00:13:50 +0200
>> Von: Jan Pieper <[EMAIL PROTECTED]>
>> An: [email protected]
>> Betreff: Re: [fw-general] Problems with Zend_Search_Lucene
>> 
>> 
>>>There is no difference between the dirname with and without the last 
>>>slash. Both of them works same.
>>>
>>>[EMAIL PROTECTED] cli]# php foo.php
>>>deletable
>>>.
>>>segments
>>>..
>>>_0.cfs
>>>
>>>-- Jan
>>>
>>>
>>>
>>>>Hi Jan,
>>>>
>>>>Please let me know, what happens if you remove last slash from dirname?
>>>>-------
>>>>$index = new Zend_Search_Lucene('../../lucene/', true);
>>>>  =>
>>>>$index = new Zend_Search_Lucene('../../lucene', true);
>>>>-------
>>>>
>>>>What is the result of:
>>>>------------
>>>>$dir = opendir('../../lucene/');
>>>>while ($file = readdir($dir)) {
>>>>    echo $file . "\n";
>>>>}
>>>>------------
>>>>and
>>>>------------
>>>>$dir = opendir('../../lucene');
>>>>while ($file = readdir($dir)) {
>>>>    echo $file . "\n";
>>>>}
>>>>------------
>>>>???
>>>>
>>>>
>>>>That also may be something wrong with directory permissions...
>>>>
>>>>With best regards,
>>>>   Alexander  Veremyev.
>>>>
>>>>Jan Pieper wrote:
>>>>
>>>>>I am using rev1290 and when I execute this:
>>>>>
>>>>><?php
>>>>>/* ... */
>>>>>echo "file_exists('../../lucene/') -> " . 
>>>>>(file_exists('../../lucene/') ? 'exists' : 'does not exist');
>>>>>$index = new Zend_Search_Lucene('../../lucene/', true);
>>>>>/* ... */
>>>>>?>
>>>>>
>>>>>I´ll get this output:
>>>>>
>>>>>file_exists('../../lucene/') -> exists
>>>>>
>>>>>Warning: opendir(../../lucene/) [function.opendir]: failed to open 
>>>>>dir: No such file or directory in 
>>>>>
>>>
>>>/var/www/html/private/lib/Zend/Search/Lucene/Storage/Directory/Filesystem.php
>>> 
>>>
>>>>>on line 129
>>>>>
>>>>>Warning: readdir(): supplied argument is not a valid Directory 
>>>>>resource in 
>>>>>
>>>
>>>/var/www/html/private/lib/Zend/Search/Lucene/Storage/Directory/Filesystem.php
>>> 
>>>
>>>>>on line 130
>>>>>
>>>>>The index will be created and I can use it but theses messages 
>>>>>shouldn´t be there.
>>>>>
>>>>>-- Jan
>>>>>
>>>>>
>>>>
>>>>
>>>>
>> 
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Problems-with-Zend_Search_Lucene-tf2432945s16154.html#a8147274
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to