|Zend Search Lucene: php timeout with small index [message #85486]
||Fri, 18 September 2009 02:56
Registered: December 2008
I have implemented a search with zend-lucene which works fine with normal queries - mostly. But as soon as I execute a search query which has more than 100 matches (e.g. searching for * or ?), the search becomes incredibly slow. It often leads me to get the 30sec php timeout while beeing in the $index->find() method of lucene.
While executing such a search, the server's cpu-load goes to 100% on at least one cpu. So this may also be a serious problem when thinking of DOS-attacks.
My code to insert to the index:
$doc = new Zend_Search_Lucene_Document();
// store content primary key to identify it in the search results
$doc->addField(Zend_Search_Lucene_Field::UnStored('ctitle', $this->getTitle(), 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::UnStored('cdescription', $this->getDescription(), 'utf-8'));
$index = MipangaContentPeer::getLuceneIndex();
My code to execute a search query:
$index = self::getLuceneIndex();
$index->setResultSetLimit( sfConfig::get('max_results_on_lucene') );
$hits = $index->find($query);
--> when more than about 200 matches exist, this function does not return within 30sec
When there are less than 20 matches, the find-method instantly returns.
I hope you can help me
See my favourite websites!
Complexity is relative. Relativity is complex. - Anonymous
Anyone who can give you orders can stop you from solving whatever problem you're being fascinated by. - Eric. S. Raymond