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


PHP Indexer::clear方法代碼示例

本文整理匯總了PHP中Indexer::clear方法的典型用法代碼示例。如果您正苦於以下問題:PHP Indexer::clear方法的具體用法?PHP Indexer::clear怎麽用?PHP Indexer::clear使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Indexer的用法示例。


在下文中一共展示了Indexer::clear方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testClear

 public function testClear()
 {
     update_option('fields', array('field1' => 1, 'field2' => 1));
     register_post_type('post');
     Indexer::addOrUpdate((object) array('post_type' => 'post', 'ID' => 1, 'field1' => 'value1', 'field2' => 'value2'));
     $this->index->refresh();
     $this->assertEquals(1, $this->index->count());
     Indexer::clear();
     $this->index->refresh();
     $this->assertEquals(0, $this->index->count());
 }
開發者ID:viz,項目名稱:wordpress-fantastic-elasticsearch,代碼行數:11,代碼來源:IndexerIntegrationTest.php

示例2: add_filter

});
add_filter('nhp-opts-saved-text-elasticsearch', function ($default) {
    if (get_transient('es-wiped') == 1) {
        return '<strong>The index has been wiped.</strong>';
        delete_transient('es-wiped');
    }
    if (get_transient('es-indexed') == 1) {
        return '<strong>The index has been populated.</strong>';
        delete_transient('es-indexed');
    }
    return $default;
});
add_action('nhp-opts-options-validate-elasticsearch', function () {
    if (isset($_POST['wipe']) && $_POST['wipe']) {
        try {
            Indexer::clear();
            set_transient('es-wiped', 1, 30);
        } catch (\Exception $ex) {
            $errors = get_transient('nhp-opts-errors-elasticsearch');
            $errors[] = array('section_id' => 'index');
            set_transient('nhp-opts-errors-elasticsearch', $errors, 1000);
            set_transient('es-wiped-error', $ex->getMessage(), 30);
        }
    }
});
ob_start();
?>

<div style="font-size: 12px; font-style: normal">
	<table class="form-table">
		<tbody>
開發者ID:makeandship,項目名稱:wordpress-fantastic-elasticsearch,代碼行數:31,代碼來源:manage-index.php

示例3: index

 public function index($domain)
 {
     $indexer = new Indexer($this->getAccountId($domain));
     $indexer->clear();
     $indexer->index();
 }
開發者ID:vichingo,項目名稱:yase,代碼行數:6,代碼來源:YASE.php

示例4: testSearchPaging

 public function testSearchPaging()
 {
     update_option('fields', array('field1' => 1));
     update_option('score_field_field1', 1);
     register_post_type('post');
     Indexer::clear();
     Indexer::addOrUpdate((object) array('post_type' => 'post', 'ID' => 1, 'post_date' => '10/24/1988 00:00:00 CST', 'field1' => 'value1'));
     Indexer::addOrUpdate((object) array('post_type' => 'post', 'ID' => 2, 'post_date' => '10/21/1988 00:00:00 CST', 'field1' => 'value1'));
     Indexer::addOrUpdate((object) array('post_type' => 'post', 'ID' => 3, 'post_date' => '10/20/1988 00:00:00 CST', 'field1' => 'value1'));
     $this->index->refresh();
     $results = $this->searcher->search('value1', 0, 1);
     $this->assertEquals(3, $results['total']);
     $first = $results['ids'][0];
     $results = $this->searcher->search('value1', 1, 1);
     $this->assertEquals(3, $results['total']);
     $second = $results['ids'][0];
     $this->assertTrue($second != $first);
     $results = $this->searcher->search('value1', 2, 1);
     $this->assertEquals(3, $results['total']);
     $this->assertTrue($results['ids'][0] != $first && $results['ids'][0] != $second);
 }
開發者ID:viz,項目名稱:wordpress-fantastic-elasticsearch,代碼行數:21,代碼來源:SearcherIntegrationTest.php

示例5: testNotAnalyzed

 public function testNotAnalyzed()
 {
     update_option('fields', array('field1' => 1));
     update_option('not_analyzed', array('field1' => 1));
     update_option('score_field_field1', 1);
     register_post_type('post');
     Indexer::clear();
     Indexer::addOrUpdate((object) array('post_type' => 'post', 'ID' => 1, 'post_date' => '10/24/1988 00:00:00 CST', 'field1' => 'foo bar'));
     $this->index->refresh();
     $results = $this->searcher->search('foo');
     $this->assertEquals(0, $results['total']);
     $this->assertEquals(array(), $results['ids']);
     $results = $this->searcher->search('foo bar');
     $this->assertEquals(0, $results['total']);
     $this->assertEquals(array(), $results['ids']);
     $results = $this->searcher->search('"foo bar"');
     $this->assertEquals(1, $results['total']);
     $this->assertEquals(array(1), $results['ids']);
 }
開發者ID:pivotlearning,項目名稱:wpsite,代碼行數:19,代碼來源:SearcherIntegrationTest.php


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