-
Notifications
You must be signed in to change notification settings - Fork 0
/
reindex.php
42 lines (29 loc) · 1 KB
/
reindex.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env php
<?php
/**
* Use this tool to reindex your wiki
*
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
* @author Abilio Marques <https://github.com/abiliojr>
*/
if(!defined('DOKU_ROOT')) define('DOKU_ROOT', realpath(dirname(__FILE__).'/../../../').'/');
define('NOSESSION', 1);
require_once(DOKU_ROOT.'inc/init.php');
global $conf;
$sphinx = new SphinxSearch();
// clear the index
idx_get_indexer()->clear();
// must complete the basic indexing first
search($data, $conf['datadir'], 'search_allpages', array('skipacl' => true));
foreach($data as $val) {
idx_addPage($val['id'], false, true);
}
// only now the backlinks counters in the dokuwiki index are valid
// so lets update sphinxsearch to reflect them
$pages = idx_get_indexer()->getPages();
foreach($pages as $page) {
$namespace = getNS($page);
if (!$namespace) $namespace = 'root';
$title = str_replace($conf['sepchar'], ' ', noNS($page));
$sphinx->updateReferences($namespace, $title, count(ft_backlinks($page, true)));
}