Prev | Current Page 221 | Next

Rob Allen, Nick Lo, and Steven Brown

"Zend Framework in Action"

com>
Please post comments or corrections to the Author Online forum at
http://www.manning-sandbox.com/forum.jspa?forumID=329
}
A Only add to index for certain events
1 Retrieve the data from the model
2 Update the search index
The notification hook function, observeTableRow() checks the event type and if the event indicates
that new data has been written to the database, then a it retrieves the data from the model (#1) and then updates
the search index files (#2). All that??™s left to do is to retrieve the data from the Model
Adding the model??™s data to the index
The process of retrieving the data from the model is a separate function as it will be used when re-indexing
the entire database and is shown in listing 8.6.
Listing 8.6: SearchIndexer::getDocument() retrieves the field information
class SearchIndexer
{
// ...
public static function getDocument($row)
{
if(method_exists($row, 'getSearchIndexFields')) { 1
$fields = $row->getSearchIndexFields($row); 2
$doc = new Places_Search_Lucene_Document( 3
$fields['class'], $fields['key'],
$fields['title'], $fields['contents'],
$fields['summary'], $fields['createdBy'],
$fields['dateCreated']);
return $doc;
}
return false;
}
// ...
1 Does a data retrieval function exist?
2 Get the the data in search index format from the model
3 Crate a new Zend_Search_Lucene_Document document
The SearchIndexer is only interested in models that need to be searched.


Pages:
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233
Turcja 1 mimre.benton.pl Biuro księgowe Lublin Fundusze Emerytalne petrozawodzkich.waw.pl