Note: Starting with release 2.1, PmWiki has a built-in page indexing system, which makes this recipe obsolete.


What can I do to make PmWiki searchbox results load faster? How can I make PmWiki find search terms faster?


The Attach:searchindex.php scripts is a PmWiki plugin, which significantly improves PmWiki's searchresult listing speed. This is realized by generating and using a special searchindex file. The plugin works within PmWikis normal searchbox, searchresult and pagelist functions.

Description and Installation

To use this script you have to do the following:

Step 1 - The Script / Generating the Search Index

First copy this script into the cookbook/ directory and add the following line to config.php (or a per-page/per-group customization file):


With this script you'll be given a special, new action 'makeindex', which can be invoked by appending '?action=makeindex' to page's address in your browser's address bar. The action is password protected and needs admin rights. The action will build (or update) a file 'searchindex.txt' in your 'local'-directory. Please use this action periodically to update the searchindex of your PmWiki installation.

Step 2 - Modify "pagelist.php"

Copy the script 'pagelist.php' from the script directory to your cookbook directory. In the new 'cookbook/pagelist.php' file include the following line after line 160 (PmWiki version 2.02: $FmtV['$MatchSearched'] = count($list); ):

if ($searchterms) $list = SearchIndexList($inclp, $exclp, $list);

NB 160 ? Is it the good line ?

154 : if (IsEnabled($EnablePageListProtect, 0)) $readf = 1000;
155 : $matches = array();
156 : $FmtV['$MatchSearched'] = count($list);
-> new line here
158 : # link= (backlinks)
159 : if (@$opt['link']) { @@
Thanks Pierre79

This change will integrate the searchindex into PmWikis standard searchbox, searchresults and pagelist functions. Please note that with every new PmWiki version, in which 'scrip/pagelist.php' is changed, you have to repeat step 2.

Step 3 - Activate the Plugin

Add the following lines to config.php (or a per-page/per-group customization file):

$EnablePageList = 0;

This command will activate the use of the searchindex script in your PmWiki.


Options that can be reconfigured in config.php:

(default: local/searchindex.txt)
Name and Path of the index file.
Variables which are used to limit the scope of the index file.

Notes and Comments

  • The index search is called every time when a searchterm is put into the searchbox or when a searchterm is included in a searchresult markup or in a pagelist markup. It can be used in combination with all pagelist and search options (= list, group, link, trail).


  • 2005-09-07 : improved pagelist integration
  • 2005-09-06 : first version of the cookbook plugin
  • This recipe was last tested on PmWiki version 2.02:
  • This recipe requires at least PmWiki version: ???

See Also

  • Cookbook/FastBacklinks - for making category pages and backlinks load faster.


  • Siegfried Seibert - 2005-09-06

Category:Searching Superceded