Page 1 of 1

Zend Lucene displays blank screen when no results found

Posted: Tue Mar 16, 2010 1:01 pm
by pixel_lab
Hi,

When I submit a query to Zend_Lucene with a string that exists in the index, the results are displayed as expected, however when string is not found, I get a blank page with no error messages. Code used as below:

Code: Select all

require_once 'Zend/Feed.php';
require_once 'Zend/Search/Lucene.php';
$index = Zend_Search_Lucene::open('data/my-index');
$queryStr ='fjkhsdkdfh';
$hits = $index->find($queryStr);

if ($hits) {

foreach ($hits as $hit) {  
   echo $hit->page_title;
}

} else {

echo 'No results found.';

}
I would expect 'No results found' to appear, but instead I get a blank page with no error messages.

What confuses me more is that I have this tested and working locally, but when on a live server it stops working.

Locally I have Zend Server 4 installed, remotely PHP 5.2.11 and ZF 1.10.2

Any help much appreciated!

Paul

Re: Zend Lucene displays blank screen when no results found

Posted: Fri Mar 19, 2010 11:34 am
by pixel_lab
Anyone run into this problem or am I all alone here?

Thanks,

Paul

Re: Zend Lucene displays blank screen when no results found

Posted: Thu Mar 25, 2010 1:04 pm
by pixel_lab
I've done a bit more debugging:

when a seach term is in index:

var_dump($hits) :

Code: Select all

array(39) { [0]=>  object(Zend_Search_Lucene_Search_QueryHit)#119 (4) { ["_index:protected"]=>  object(Zend_Search_Lucene_Proxy)#120 (1) { ["_index:private"]=>  object(Zend_Search_Lucene)#4 (11) { ["_directory:private"]=>  object(Zend_Search_Lucene_Storage_Directory_Filesystem)#14 (2) { ["_dirPath:protected"]=>  string(14) "data/index" ["_fileHandlers:protected"]=>  array(12) { ["read.lock.file"]=>  object(Zend_Search_Lucene_Storage_File_Filesystem)#13 (1) { ["_fileHandle:protected"]=>  resource(2) of type (stream) } ["segments_7"]=> 
(..truncated)

when a search term is not in index:

var_dump($hits) :

blank page

So why the hell is a blank page, no error message or anything appearing?

Re: Zend Lucene displays blank screen when no results found

Posted: Sat Mar 27, 2010 5:58 pm
by juggernt
I've seen this problem..on the same version. Actually, it may have been exactly when I was upgrading to 1.10 r2. Unfortunately, I was super-rushed at the time & not horribly methodical in my troubleshooting.

I can only say there were 2 behaviors/symptoms occurring simultaneously that may?? give a little insight. ( I'm more inclined to think they're just other symptoms..or even unrelated.)

#1) I started getting the new error "search term must be a STRING or a QUERY obj".. and this problem was occurring with the find() method w/near identical code like you displayed in your first post.

As a result, though. I just added (string) to cast all data as strings going into it, and that seemed to do the trick.

#2) Then, when I experienced probs on another of my site's search forms, I realized during my hasty testing of it I was only using 2 char keywords.. and the min length, that I recall, was supposed to be 3 (and wasn't happening, it seemed on 3 char keyword searches... so I updated my client-side and server-side validation to prevent <=2 char keyword searches.

Again, probably not very helpful..but at least you're not alone.. :) .. in seeing the blank screen behavior.

-Jay

Re: Zend Lucene displays blank screen when no results found

Posted: Mon Mar 29, 2010 11:22 am
by pixel_lab
Hi Jay,

Thanks for the time in responding to this.

I have tried your suggestions but to no avail - still a blank screen with:

Code: Select all

$queryStr = (string) $queryStr;
I have tested this again and again and from what I can surmise is that because I am including some external files, namely structural code such as a header for formatting (which also requires a functions class), a bug(?) makes Zend_Lucene return a blank screen if no results are found.

I have tested the same code as above with out the included files and the script works. So for some reason, the addition of my code makes Zend_Lucene fall over when no results are found, but only on my production server. It works as expeced on my development server...

Its all a little bit strange!

Cheers,

Paul

Re: Zend Lucene displays blank screen when no results found

Posted: Fri Apr 16, 2010 6:13 am
by geo22
i think u people must include external files related this code to use this code....
may be it will be ok...i will also try it today....i am sure that i will get it...

Re: Zend Lucene displays blank screen when no results found

Posted: Wed Apr 04, 2018 10:45 am
by john5967
i think u people must include external files related this code.