Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...

When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Field names

There are no limitations for field names in Zend_Search_Lucene.

Nevertheless it's a good idea not to use 'id' and 'score' names to avoid ambiguity in QueryHit properties names.

The Zend_Search_Lucene_Search_QueryHit id and score properties always refer to internal Lucene document id and hit score. If the indexed document has the same stored fields, you have to use the getDocument() method to access them:


foreach (
$hits as $hit) {
// Get 'title' document field
$title $hit->title;

// Get 'contents' document field
$contents $hit->contents;

// Get internal Lucene document id
$id $hit->id;

// Get query hit score
$score $hit->score;

// Get 'id' document field
$docId $hit->getDocument()->id;

// Get 'score' document field
$docId $hit->getDocument()->score;

// Another way to get 'title' document field
$title $hit->getDocument()->title;

Zend Framework