
03-23-2008, 06:52 PM
|
|
Junior Member
|
|
Join Date: Mar 2008
Posts: 8
|
|
no results
Code:
function findAction()
{
$index = Zend_Search_Lucene::open('/var/www/firmy/data/indexes/index');
if ($this->_request->isPost()) {
Zend_Loader::loadClass('Zend_Filter_StripTags');
$filter=new Zend_Filter_StripTags();
$string=trim($filter->filter($this->_request->getPost('string')));
$what=trim($filter->filter($this->_request->getPost('typ')));
$index_path="/var/www/firmy/data/indexes/index";
$index = Zend_Search_Lucene::open($index_path);
$name = $string;
$term = new Zend_Search_Lucene_Index_Term($name, $what);
$name = new Zend_Search_Lucene_Search_Query_Term($term);
echo $name;
$this->view->results = $index->find($name);
}
}
indexer.php :
Quote:
<?php
// Add your vendor directory to the includepath. ZF needs this.
//ini_set('include_path', ini_get('include_path') . ':' . dirname(__FILE__) . '/vendors');
// Require the Lucene Class
require_once('Zend/Search/Lucene.php');
// Establish your connection to the database
mysql_connect('localhost', 'root', '');
mysql_select_db('zend');
// Create a new index. This folder has to be readable by the httpd user
// I will use the cache directory to store the index data
$indexPath = dirname(__FILE__) . '/firmy/data/indexes/index';
$index = new Zend_Search_Lucene($indexPath, true);
// Lets get some records to add to the index
$documents_rs = mysql_query('SELECT * FROM posts');
while($document = mysql_fetch_object($documents_rs)) {
// Create a new searchable document instance
$doc = new Zend_Search_Lucene_Document();
// Add some information
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('id' , $document->id));
$doc->addField(Zend_Search_Lucene_Field::Text('name', $document->name));
$doc->addField(Zend_Search_Lucene_Field::Text('post', $document->post));
$doc->addField(Zend_Search_Lucene_Field::Keyword('id_no ', $document->id_no));
$doc->addField(Zend_Search_Lucene_Field::Text('activity ', $document->activity));
//$doc->addField(Zend_Search_Lucene_Field::Text('document _description', $document->description));
// Add the document to the index
$index->addDocument($doc);
}
// Commit the index
$index->commit();
echo 'OK';
?>
|
Last edited by garfield : 03-23-2008 at 07:01 PM.
|