/** * Set result set limit. * * 0 means no limit * * @return integer */ public static function getResultSetLimit() { return Zend_Search_Lucene::getResultSetLimit(); }
public function testLimitingResult() { $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_index23Sample/_files'); $storedResultSetLimit = Zend_Search_Lucene::getResultSetLimit(); Zend_Search_Lucene::setResultSetLimit(3); $hits = $index->find('"reporting bugs"', 'path'); $this->assertEquals(count($hits), 3); $expectedResultset = array(array(7, 0.212395, 'IndexSource/contributing.bugs.html'), array(0, 0.247795, 'IndexSource/contributing.documentation.html'), array(2, 0.176996, 'IndexSource/contributing.patches.html')); foreach ($hits as $resId => $hit) { $this->assertEquals($hit->id, $expectedResultset[$resId][0]); $this->assertTrue(abs($hit->score - $expectedResultset[$resId][1]) < 1.0E-6); $this->assertEquals($hit->path, $expectedResultset[$resId][2]); } Zend_Search_Lucene::setResultSetLimit($storedResultSetLimit); }