本文整理汇总了PHP中Zend\Search\Lucene\Lucene::open方法的典型用法代码示例。如果您正苦于以下问题:PHP Lucene::open方法的具体用法?PHP Lucene::open怎么用?PHP Lucene::open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Search\Lucene\Lucene
的用法示例。
在下文中一共展示了Lucene::open方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
/**
* @returns \Zend\Search\Lucene\SearchIndexInterface
*/
public function get()
{
if (!$this->checkEsists()) {
return Lucene::create($this->path);
} else {
return Lucene::open($this->path);
}
}
示例2: testFind
/**
* @covers Zend\Search\Lucene\MultiSearcher::find
* @covers Zend\Search\Lucene\Search\QueryHit::getDocument
*/
public function testFind()
{
$index = new Lucene\MultiSearcher(array(Lucene\Lucene::open(__DIR__ . '/_indexSample/_files'), Lucene\Lucene::open(__DIR__ . '/_indexSample/_files')));
$hits = $index->find('submitting');
$this->assertEquals(count($hits), 2 * 3);
foreach ($hits as $hit) {
$document = $hit->getDocument();
$this->assertTrue($document instanceof Lucene\Document);
}
}
示例3: run
/**
* Transforms given objects into a bulk add operation directive
*
* @param ClassMetadata $metadata
* @param array $objects
* @param array bulk commands
*/
public function run(ClassMetadata $metadata, array $objects)
{
$index = $metadata->getIndex()->getName();
$index = Lucene::open("/tmp/index_$index");
foreach ($objects as $object) {
$document = $this->exportObject($metadata, $object);
$index->addDocument($document);
}
}
示例4: run
/**
* (non-PHPdoc)
* @see Ariadne\Engine.Engine::search()
*/
public function run(ClassMetadata $metadata, Query $query)
{
$index = $metadata->getIndex()->getName();
$type = $metadata->getClassName();
$arguments = $this->mapQuery($query);
$index = Lucene::open("/tmp/index_$index");
$result = call_user_func_array(array($index, 'find'), $arguments);
return $this->mapResult($result, $metadata, $query);
}
示例5: testLimitingResult
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);
}
示例6: testTermsStreamInterfaceSkipToTermsRetrievingTwoTermsCase
public function testTermsStreamInterfaceSkipToTermsRetrievingTwoTermsCase()
{
$index = Lucene\Lucene::create(__DIR__ . '/_index/_files');
// Zero terms
$doc = new Document();
$doc->addField(Document\Field::Text('contents', 'someterm word'));
$index->addDocument($doc);
unset($index);
$index = Lucene\Lucene::open(__DIR__ . '/_index/_files');
$index->resetTermsStream();
$index->skipTo(new Index\Term('term', 'contents'));
$this->assertTrue($index->currentTerm() == new Index\Term('word', 'contents'));
$index->closeTermsStream();
}