本文整理汇总了PHP中Indexer::reindex方法的典型用法代码示例。如果您正苦于以下问题:PHP Indexer::reindex方法的具体用法?PHP Indexer::reindex怎么用?PHP Indexer::reindex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Indexer
的用法示例。
在下文中一共展示了Indexer::reindex方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: reindex
function reindex()
{
try {
echo Indexer::reindex($_POST['page']);
} catch (\Exception $ex) {
header("HTTP/1.0 500 Internal Server Error");
echo $ex->getMessage();
}
die;
}
示例2: add_action
<?php
namespace elasticsearch;
add_action('wp_ajax_esreindex', function () {
try {
echo Indexer::reindex($_POST['page']);
} catch (\Exception $ex) {
header("HTTP/1.0 500 Internal Server Error");
echo $ex->getMessage();
}
die;
});
add_action('admin_head-toplevel_page_elastic_search', function () {
wp_enqueue_script('es-indexing', plugins_url('/manage-index.js', __FILE__), array('jquery'));
wp_localize_script('es-indexing', 'indexing', array('ajaxurl' => admin_url('admin-ajax.php'), 'total' => Indexer::get_count(), 'perpage' => Indexer::per_page()));
});
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 {
示例3: testMapDate
public function testMapDate()
{
update_option('fields', array('post_date' => 1));
register_post_type('post');
wp_insert_post(array('post_type' => 'post', 'post_date' => '07/30/1989 00:00:00 CST'));
wp_insert_post(array('post_type' => 'post', 'post_date' => '10/30/1988 00:00:00 CST'));
Indexer::_map();
Indexer::reindex();
$this->index->refresh();
$search = new \Elastica\Search($this->index->getClient());
$search->addIndex($this->index);
$results = $search->search(new \Elastica\Query(array('sort' => array('post_date' => array('order' => 'asc')))))->getResults();
$this->assertCount(2, $results);
$this->assertEquals(2, $results[0]->getId());
$this->assertEquals(1, $results[1]->getId());
$results = $search->search(new \Elastica\Query(array('sort' => array('post_date' => array('order' => 'desc')))))->getResults();
$this->assertCount(2, $results);
$this->assertEquals(1, $results[0]->getId());
$this->assertEquals(2, $results[1]->getId());
}