View Single Post
  #2 (permalink)  
Old 08-24-2007, 12:42 PM
kees kees is offline
Junior Member
 
Join Date: Jul 2007
Posts: 7
Default

Maybe it's a little late to answer your question. But could something like this:

<?php
if(in_array('afieldname',$result->getDocument()->getFieldNames()))
?>

It's a bit strange that there is no function to check wether a field exists or not...

Another solution is to catch the exception:
<?
$field = 'news_title';
try {
$result->$field;
} catch(Zend_Search_Lucene_Exception $e) {
switch($e->getMessage()) {
case 'Field name '.$field.' not found in document.' :
break;
}
}
?>

But i think that is really a nasty solution, they should have an Zend_Search_Lucene_Field_Exception with an code (example 10 means it not exists)..

Last edited by kees : 08-24-2007 at 12:47 PM.
Reply With Quote