当前位置: 首页>>代码示例>>PHP>>正文


PHP Index::refresh方法代码示例

本文整理汇总了PHP中Elastica\Index::refresh方法的典型用法代码示例。如果您正苦于以下问题:PHP Index::refresh方法的具体用法?PHP Index::refresh怎么用?PHP Index::refresh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Elastica\Index的用法示例。


在下文中一共展示了Index::refresh方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->_index = $this->_createIndex("simple_query_string_test");
     $docs = array(new Document(1, array('make' => 'Gibson', 'model' => 'Les Paul')), new Document(2, array('make' => 'Gibson', 'model' => 'SG Standard')), new Document(3, array('make' => 'Gibson', 'model' => 'SG Supreme')), new Document(4, array('make' => 'Gibson', 'model' => 'SG Faded')), new Document(5, array('make' => 'Fender', 'model' => 'Stratocaster')));
     $this->_index->getType("guitars")->addDocuments($docs);
     $this->_index->refresh();
 }
开发者ID:viz,项目名称:wordpress-fantastic-elasticsearch,代码行数:8,代码来源:SimpleQueryStringTest.php

示例2: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->_index = $this->_createIndex("query");
     $docs = array(new Document("1", array("color" => "green", "make" => "ford")), new Document("2", array("color" => "blue", "make" => "volvo")), new Document("3", array("color" => "red", "make" => "ford")), new Document("4", array("color" => "green", "make" => "renault")));
     $this->_index->getType("test")->addDocuments($docs);
     $this->_index->refresh();
 }
开发者ID:tkaven,项目名称:Elastica,代码行数:8,代码来源:PostFilterTest.php

示例3: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->index = $this->_createIndex('test_functionscore');
     $this->type = $this->index->getType('test');
     $this->type->setMapping(array('name' => array('type' => 'string', 'index' => 'not_analyzed'), 'location' => array('type' => 'geo_point'), 'price' => array('type' => 'float')));
     $this->type->addDocument(new Document(1, array('name' => "Mr. Frostie's", 'location' => array('lat' => 32.799605, 'lon' => -117.243027), 'price' => 4.5)));
     $this->type->addDocument(new Document(2, array('name' => "Miller's Field", 'location' => array('lat' => 32.795964, 'lon' => -117.255028), 'price' => 9.5)));
     $this->index->refresh();
 }
开发者ID:viz,项目名称:wordpress-fantastic-elasticsearch,代码行数:10,代码来源:FunctionScoreTest.php

示例4: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->index = $this->_createIndex('test_boostingquery');
     $this->type = $this->index->getType('test');
     $this->type->setMapping(array('name' => array('type' => 'string', 'index' => 'analyzed'), 'price' => array('type' => 'float')));
     $this->sampleData = array(array("name" => "Vital Lama", "price" => 5.2), array("name" => "Vital Match", "price" => 2.1), array("name" => "Mercury Vital", "price" => 7.5), array("name" => "Fist Mercury", "price" => 3.8), array("name" => "Lama Vital 2nd", "price" => 3.2));
     foreach ($this->sampleData as $key => $value) {
         $this->type->addDocument(new Document($key, $value));
     }
     $this->index->refresh();
 }
开发者ID:viz,项目名称:wordpress-fantastic-elasticsearch,代码行数:12,代码来源:BoostingTest.php

示例5: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->_index1 = $this->_createIndex('indices_filter_1');
     $this->_index2 = $this->_createIndex('indices_filter_2');
     $this->_index1->addAlias("indices_filter");
     $this->_index2->addAlias("indices_filter");
     $docs = array(new Document("1", array("color" => "blue")), new Document("2", array("color" => "green")), new Document("3", array("color" => "blue")), new Document("4", array("color" => "yellow")));
     $this->_index1->getType("test")->addDocuments($docs);
     $this->_index2->getType("test")->addDocuments($docs);
     $this->_index1->refresh();
     $this->_index2->refresh();
 }
开发者ID:tkaven,项目名称:Elastica,代码行数:13,代码来源:IndicesTest.php

示例6: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->_index = $this->_createIndex('test_suggest_phrase');
     $docs = array();
     $docs[] = new Document(1, array('text' => 'Github is pretty cool'));
     $docs[] = new Document(2, array('text' => 'Elasticsearch is bonsai cool'));
     $docs[] = new Document(3, array('text' => 'This is a test phrase'));
     $docs[] = new Document(4, array('text' => 'Another sentence for testing'));
     $docs[] = new Document(5, array('text' => 'Some more words here'));
     $type = $this->_index->getType(self::TEST_TYPE);
     $type->addDocuments($docs);
     $this->_index->refresh();
 }
开发者ID:viz,项目名称:wordpress-fantastic-elasticsearch,代码行数:14,代码来源:PhraseTest.php

示例7: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->_index = $this->_createIndex('test_suggest');
     $docs = array();
     $docs[] = new Document(1, array('id' => 1, 'text' => 'GitHub'));
     $docs[] = new Document(2, array('id' => 1, 'text' => 'Elastic'));
     $docs[] = new Document(3, array('id' => 1, 'text' => 'Search'));
     $docs[] = new Document(4, array('id' => 1, 'text' => 'Food'));
     $docs[] = new Document(5, array('id' => 1, 'text' => 'Flood'));
     $docs[] = new Document(6, array('id' => 1, 'text' => 'Folks'));
     $type = $this->_index->getType(self::TEST_TYPE);
     $type->addDocuments($docs);
     $this->_index->refresh();
 }
开发者ID:viz,项目名称:wordpress-fantastic-elasticsearch,代码行数:15,代码来源:TermTest.php

示例8: testSearch

 /**
  * @group functional
  */
 public function testSearch()
 {
     $client = $this->_getClient();
     $index = new Index($client, 'test');
     $index->create(array(), true);
     $type = new Type($index, 'helloworld');
     $doc = new Document(1, array('id' => 1, 'email' => 'hans@test.com', 'username' => 'hans', 'test' => array('2', '3', '5')));
     $type->addDocument($doc);
     $doc = new Document(2, array('id' => 2, 'email' => 'emil@test.com', 'username' => 'emil', 'test' => array('1', '3', '6')));
     $type->addDocument($doc);
     $doc = new Document(3, array('id' => 3, 'email' => 'ruth@test.com', 'username' => 'ruth', 'test' => array('2', '3', '7')));
     $type->addDocument($doc);
     // Refresh index
     $index->refresh();
     $boolQuery = new BoolQuery();
     $termQuery1 = new Term(array('test' => '2'));
     $boolQuery->addMust($termQuery1);
     $resultSet = $type->search($boolQuery);
     $this->assertEquals(2, $resultSet->count());
     $termQuery2 = new Term(array('test' => '5'));
     $boolQuery->addMust($termQuery2);
     $resultSet = $type->search($boolQuery);
     $this->assertEquals(1, $resultSet->count());
     $termQuery3 = new Term(array('username' => 'hans'));
     $boolQuery->addMust($termQuery3);
     $resultSet = $type->search($boolQuery);
     $this->assertEquals(1, $resultSet->count());
     $termQuery4 = new Term(array('username' => 'emil'));
     $boolQuery->addMust($termQuery4);
     $resultSet = $type->search($boolQuery);
     $this->assertEquals(0, $resultSet->count());
 }
开发者ID:MediaWiki-stable,项目名称:1.26.0,代码行数:35,代码来源:BoolQueryTest.php

示例9: reindex

 /**
  * Dump everything from the live index into the one being worked on.
  *
  * @param int $processes
  * @param int $refreshInterval
  * @param int $retryAttempts
  * @param int $chunkSize
  * @param float $acceptableCountDeviation
  */
 public function reindex($processes = 1, $refreshInterval = 1, $retryAttempts = 5, $chunkSize = 100, $acceptableCountDeviation = 0.05)
 {
     global $wgCirrusSearchWikimediaExtraPlugin;
     // Set some settings that should help io load during bulk indexing.  We'll have to
     // optimize after this to consolidate down to a proper number of shards but that is
     // is worth the price.  total_shards_per_node will help to make sure that each shard
     // has as few neighbors as possible.
     $settings = $this->index->getSettings();
     $maxShardsPerNode = $this->decideMaxShardsPerNodeForReindex();
     $settings->set(array('refresh_interval' => -1, 'merge.policy.segments_per_tier' => 40, 'merge.policy.max_merge_at_once' => 40, 'routing.allocation.total_shards_per_node' => $maxShardsPerNode));
     $sender = new DataSender($this->connection);
     $frozenIndexes = $this->connection->indexToIndexTypes($this->types);
     $sender->freezeIndexes($frozenIndexes);
     if ($processes > 1) {
         if (!isset($wgCirrusSearchWikimediaExtraPlugin['id_hash_mod_filter']) || !$wgCirrusSearchWikimediaExtraPlugin['id_hash_mod_filter']) {
             $this->error("Can't use multiple processes without \$wgCirrusSearchWikimediaExtraPlugin[ 'id_hash_mod_filter' ] = true", 1);
         }
         $fork = new ForkController($processes);
         $forkResult = $fork->start();
         // we don't want to share sockets between forks, so destroy the client.
         $this->connection->destroyClient();
         // destroying the client resets the timeout so we have to reinstate it.
         $this->setConnectionTimeout();
         switch ($forkResult) {
             case 'child':
                 foreach ($this->types as $i => $type) {
                     $oldType = $this->oldTypes[$i];
                     $this->reindexInternal($type, $oldType, $processes, $fork->getChildNumber(), $chunkSize, $retryAttempts);
                 }
                 die(0);
             case 'done':
                 break;
             default:
                 $this->error("Unexpected result while forking:  {$forkResult}", 1);
         }
         $this->outputIndented("Verifying counts...");
         // We can't verify counts are exactly equal because they won't be - we still push updates into
         // the old index while reindexing the new one.
         foreach ($this->types as $i => $type) {
             $oldType = $this->oldTypes[$i];
             $oldCount = (double) $oldType->count();
             $this->index->refresh();
             $newCount = (double) $type->count();
             $difference = $oldCount > 0 ? abs($oldCount - $newCount) / $oldCount : 0;
             if ($difference > $acceptableCountDeviation) {
                 $this->output("Not close enough!  old={$oldCount} new={$newCount} difference={$difference}\n");
                 $this->error('Failed to load index - counts not close enough.  ' . "old={$oldCount} new={$newCount} difference={$difference}.  " . 'Check for warnings above.', 1);
             }
         }
         $this->output("done\n");
     } else {
         foreach ($this->types as $i => $type) {
             $oldType = $this->oldTypes[$i];
             $this->reindexInternal($type, $oldType, 1, 1, $chunkSize, $retryAttempts);
         }
     }
     // Revert settings changed just for reindexing
     $settings->set(array('refresh_interval' => $refreshInterval . 's', 'merge.policy' => $this->mergeSettings));
     $sender->thawIndexes($frozenIndexes);
 }
开发者ID:jamesmontalvo3,项目名称:mediawiki-extensions-CirrusSearch,代码行数:69,代码来源:Reindexer.php

示例10: testSearch

 /**
  * @group functional
  */
 public function testSearch()
 {
     $client = $this->_getClient();
     $index = new Index($client, 'test');
     $index->create(array(), true);
     $index->getSettings()->setNumberOfReplicas(0);
     //$index->getSettings()->setNumberOfShards(1);
     $type = new Type($index, 'helloworldmlt');
     $mapping = new Mapping($type, array('email' => array('store' => 'yes', 'type' => 'string', 'index' => 'analyzed'), 'content' => array('store' => 'yes', 'type' => 'string', 'index' => 'analyzed')));
     $mapping->setSource(array('enabled' => false));
     $type->setMapping($mapping);
     $doc = new Document(1000, array('email' => 'testemail@gmail.com', 'content' => 'This is a sample post. Hello World Fuzzy Like This!'));
     $type->addDocument($doc);
     $doc = new Document(1001, array('email' => 'nospam@gmail.com', 'content' => 'This is a fake nospam email address for gmail'));
     $type->addDocument($doc);
     // Refresh index
     $index->refresh();
     $mltQuery = new MoreLikeThis();
     $mltQuery->setLike('fake gmail sample');
     $mltQuery->setFields(array('email', 'content'));
     $mltQuery->setMaxQueryTerms(3);
     $mltQuery->setMinDocFrequency(1);
     $mltQuery->setMinTermFrequency(1);
     $query = new Query();
     $query->setQuery($mltQuery);
     $resultSet = $type->search($query);
     $resultSet->getResponse()->getData();
     $this->assertEquals(2, $resultSet->count());
 }
开发者ID:makeandship,项目名称:wordpress-fantastic-elasticsearch,代码行数:32,代码来源:MoreLikeThisTest.php

示例11: testQuery

 public function testQuery()
 {
     $client = $this->_getClient();
     $index = new Index($client, 'test');
     $index->create(array(), true);
     $type = new Type($index, 'constant_score');
     $doc = new Document(1, array('id' => 1, 'email' => 'hans@test.com', 'username' => 'hans'));
     $type->addDocument($doc);
     $doc = new Document(2, array('id' => 2, 'email' => 'emil@test.com', 'username' => 'emil'));
     $type->addDocument($doc);
     $doc = new Document(3, array('id' => 3, 'email' => 'ruth@test.com', 'username' => 'ruth'));
     $type->addDocument($doc);
     // Refresh index
     $index->refresh();
     $boost = 1.3;
     $query_match = new MatchAll();
     $query = new ConstantScore();
     $query->setQuery($query_match);
     $query->setBoost($boost);
     $expectedArray = array('constant_score' => array('query' => $query_match->toArray(), 'boost' => $boost));
     $this->assertEquals($expectedArray, $query->toArray());
     $resultSet = $type->search($query);
     $results = $resultSet->getResults();
     $this->assertEquals($resultSet->count(), 3);
     $this->assertEquals($results[1]->getScore(), 1);
 }
开发者ID:viz,项目名称:wordpress-fantastic-elasticsearch,代码行数:26,代码来源:ConstantScoreTest.php

示例12: createNewDocumentOnSave

 /**
  * @test
  */
 public function createNewDocumentOnSave()
 {
     $id = 1;
     $data = 'foobar';
     $this->prophesizeGetDocumentThrowsException($id);
     $this->index->refresh()->shouldBeCalled();
     $doc = $this->getDocument($id, $data);
     $this->type->createDocument($this->getCacheId($id), [Cache::VALUE_FIELD => serialize($data)])->shouldBeCalled()->willReturn($doc);
     $this->type->addDocument($doc)->shouldBeCalled();
     self::assertTrue($this->cache->save($id, $data));
 }
开发者ID:basster,项目名称:doctrine-elastica-cache,代码行数:14,代码来源:CacheTest.php

示例13: testSnapshotAndRestore

 /**
  * @group functional
  */
 public function testSnapshotAndRestore()
 {
     $repositoryName = 'testrepo';
     $location = $this->_snapshotPath . 'backup2';
     // register the repository
     $response = $this->_snapshot->registerRepository($repositoryName, 'fs', array('location' => $location));
     $this->assertTrue($response->isOk());
     // create a snapshot of our test index
     $snapshotName = 'test_snapshot_1';
     $response = $this->_snapshot->createSnapshot($repositoryName, $snapshotName, array('indices' => $this->_index->getName()), true);
     // ensure that the snapshot was created properly
     $this->assertTrue($response->isOk());
     $this->assertArrayHasKey('snapshot', $response->getData());
     $data = $response->getData();
     $this->assertContains($this->_index->getName(), $data['snapshot']['indices']);
     $this->assertEquals(1, sizeof($data['snapshot']['indices']));
     // only the specified index should be present
     $this->assertEquals($snapshotName, $data['snapshot']['snapshot']);
     // retrieve data regarding the snapshot
     $response = $this->_snapshot->getSnapshot($repositoryName, $snapshotName);
     $this->assertContains($this->_index->getName(), $response['indices']);
     // delete our test index
     $this->_index->delete();
     // restore the index from our snapshot
     $response = $this->_snapshot->restoreSnapshot($repositoryName, $snapshotName, array(), true);
     $this->assertTrue($response->isOk());
     $this->_index->refresh();
     $this->_index->optimize();
     // ensure that the index has been restored
     $count = $this->_index->getType('test')->count();
     $this->assertEquals(sizeof($this->_docs), $count);
     // delete the snapshot
     $response = $this->_snapshot->deleteSnapshot($repositoryName, $snapshotName);
     $this->assertTrue($response->isOk());
     // ensure that the snapshot has been deleted
     $this->setExpectedException('Elastica\\Exception\\NotFoundException');
     $this->_snapshot->getSnapshot($repositoryName, $snapshotName);
 }
开发者ID:makeandship,项目名称:wordpress-fantastic-elasticsearch,代码行数:41,代码来源:SnapshotTest.php

示例14: testSnapshotAndRestore

 public function testSnapshotAndRestore()
 {
     $repositoryName = "test_repository";
     $location = "/tmp/{$repositoryName}";
     // register the repository
     $response = $this->_snapshot->registerRepository($repositoryName, "fs", array("location" => $location));
     $this->assertTrue($response->isOk());
     // create a snapshot of our test index
     $snapshotName = "test_snapshot_1";
     $response = $this->_snapshot->createSnapshot($repositoryName, $snapshotName, array("indices" => $this->_index->getName()), true);
     // ensure that the snapshot was created properly
     $this->assertTrue($response->isOk());
     $this->assertArrayHasKey("snapshot", $response->getData());
     $data = $response->getData();
     $this->assertContains($this->_index->getName(), $data["snapshot"]["indices"]);
     $this->assertEquals(1, sizeof($data["snapshot"]["indices"]));
     // only the specified index should be present
     $this->assertEquals($snapshotName, $data["snapshot"]["snapshot"]);
     // retrieve data regarding the snapshot
     $response = $this->_snapshot->getSnapshot($repositoryName, $snapshotName);
     $this->assertContains($this->_index->getName(), $response["indices"]);
     // delete our test index
     $this->_index->delete();
     // restore the index from our snapshot
     $response = $this->_snapshot->restoreSnapshot($repositoryName, $snapshotName, array(), true);
     $this->assertTrue($response->isOk());
     $this->_index->refresh();
     $this->_index->optimize();
     // ensure that the index has been restored
     $count = $this->_index->getType("test")->count();
     $this->assertEquals(sizeof($this->_docs), $count);
     // delete the snapshot
     $response = $this->_snapshot->deleteSnapshot($repositoryName, $snapshotName);
     $this->assertTrue($response->isOk());
     // ensure that the snapshot has been deleted
     $this->setExpectedException('Elastica\\Exception\\NotFoundException');
     $this->_snapshot->getSnapshot($repositoryName, $snapshotName);
 }
开发者ID:viz,项目名称:wordpress-fantastic-elasticsearch,代码行数:38,代码来源:SnapshotTest.php

示例15: testSearch

 public function testSearch()
 {
     $client = $this->_getClient();
     $index = new Index($client, 'test');
     $index->create(array(), true);
     $index->getSettings()->setNumberOfReplicas(0);
     //$index->getSettings()->setNumberOfShards(1);
     $type = new Type($index, 'helloworld');
     $doc = new Document(1, array('email' => 'test@test.com', 'username' => 'hanswurst', 'test' => array('2', '3', '5')));
     $type->addDocument($doc);
     // Refresh index
     $index->refresh();
     $queryString = new QueryString('test*');
     $resultSet = $type->search($queryString);
     $this->assertEquals(1, $resultSet->count());
 }
开发者ID:viz,项目名称:wordpress-fantastic-elasticsearch,代码行数:16,代码来源:QueryStringTest.php


注:本文中的Elastica\Index::refresh方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。