예제 #1
0
 public function testLimitingResult()
 {
     $index = Lucene\Lucene::open(dirname(__FILE__) . '/_index23Sample/_files');
     $storedResultSetLimit = Lucene\Lucene::getResultSetLimit();
     Lucene\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]);
     }
     Lucene\Lucene::setResultSetLimit($storedResultSetLimit);
 }