search_index_location,!file_exists( fConfig::getInstance()->search_index_location . '/segments' ));
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::Keyword('pagina', 'p'.$id));
$doc->addField(Zend_Search_Lucene_Field::Keyword('link', $link));
$doc->addField(Zend_Search_Lucene_Field::Text('title', $title));
$doc->addField(Zend_Search_Lucene_Field::Unstored('contents', $contents));
$index->addDocument( $doc );
$index->commit();
}
public function deleteFromIndex($id) {
$index = new Zend_Search_Lucene(fConfig::getInstance()->search_index_location);
$hits = $index->find('pagina:"p'.$id.'"');
foreach ( $hits as $hit ) {
$index->delete($hit->id);
$index->commit();
}
}
}
if ( isset( $params['index'] ) ) {
$res = $db->query( 'SELECT * FROM paginas' );
while( $rec = $res->fetchRow() ) {
Page::updateIndex($rec->friendly_url,$rec->titel,$rec->inhoud, $rec->id);
}
}
if ( isset( $params['delete'] ) ) {
Page::deleteFromIndex($params['delete']);
}
$index = new Zend_Search_Lucene(fConfig::getInstance()->search_index_location);
$query = 'a';
$hits = $index->find($query);
echo "Index contains ".$index->count()." documents.
";
echo "Search for '".$query."' returned " .count($hits). " hits
";
foreach ($hits as $hit) {
?>