當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Lucene::open方法代碼示例

本文整理匯總了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);
     }
 }
開發者ID:risinglf,項目名稱:UniversiBO,代碼行數:11,代碼來源:LuceneFactory.php

示例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);
     }
 }
開發者ID:robertodormepoco,項目名稱:zf2,代碼行數:14,代碼來源:MultiIndexTest.php

示例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);
        }
    }
開發者ID:nresni,項目名稱:Ariadne,代碼行數:18,代碼來源:AddToIndex.php

示例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);
    }
開發者ID:nresni,項目名稱:Ariadne,代碼行數:18,代碼來源:SearchIndex.php

示例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);
 }
開發者ID:bradley-holt,項目名稱:zf2,代碼行數:15,代碼來源:Search23Test.php

示例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();
 }
開發者ID:rikaix,項目名稱:zf2,代碼行數:14,代碼來源:IndexTest.php


注:本文中的Zend\Search\Lucene\Lucene::open方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。