zend_search_lucene - how to achieve this ?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

zend_search_lucene - how to achieve this ?

mghipparagi
This post has NOT been accepted by the mailing list yet.
Hi all,
I am using zend search lucene for searching sentences in a paragraph and below is the sample code I used to search.

FOR CREATING INDEX:
----------------------------------

$this->content="This enabled me to improve my presentation skills, experience taking a Q&A session and learn to work to deadlines.";


require_once '/home/project/mgh/lib/Zend/Search/Lucene.php';
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum_CaseInsensitive());
$index = new Zend_Search_Lucene('/home/project/mgh/data/search_file/lucene.customer.index',true);
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::unIndexed('URL', $file1_path));
$doc->addField(Zend_Search_Lucene_Field::text('contents',$this->content));
$index->addDocument($doc);
$index->commit();

for searching
------------------

require_once('Zend/Search/Lucene.php');
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum_CaseInsensitive());
$index = new Zend_Search_Lucene('/home/project/mgh/data/search_file/lucene.customer.index');
Zend_Search_Lucene::getDefaultSearchField('contents');
$results = $index->find('contents:"improve my extra skills" ');
$this->count=count($results);

On searching for "improve my presentation skills" it is resulting 0 result count.
Actually, words like improve - my - skills will get matched but only word 'extra' will not be matched.

How to get result count even if few words are matched and few gets unmatched...

Please reply..
Thanks in advance.