Table of Contents
elasticsearch Plugin
Compatible with DokuWiki
- 2022-07-31 "Igor" yes
- 2020-07-29 "Hogfather" yes
- 2018-04-22 "Greebo" yes
- 2017-02-19 "Frusterick Manners" unknown
Similar to docsearch
Installation
External requirements: This plugin requires the following additional components that must be installed separately:
- Elasticsearch instance (latest tested version 7.11)
Install the plugin using the Plugin Manager and the download URL above, which points to latest version of the plugin. Refer to Plugins on how to install plugins manually.
Configure and setup the plugin as outlined under Configuration below.
Examples/Usage
Once installed, the plugin will automatically react on the ?do=search action, replacing DokuWiki's builtin search. However, the typical DokuWiki query shortcuts (like @namespace) do not work in ElasticSearch.
All access rights are respected, so users will only find pages for which they have at least read privileges.
You can use the Advanced Search Tools to filter the results by namespace and date of the last modification. With tagging plugin installed, the search tools will include a dropdown with tags available for the current result set. So if none of the current results are tagged, the filter will not be displayed.
If the text plugin is installed, the rendered content of pages will be indexed in addition to raw wiki syntax. By default, search uses both fields. If you want to disable search in syntax, change the searchSyntax
setting in the plugin's configuration.
Configuration and Settings
To integrate this plugin, you will need to do some configuration and run a few commands on the command line.
- enter the configuration of your Elasticsearch server in the Configuration Settings
- copy and adjust a sample configuration for media indexing
- create the Index
- create the Language Mappings (only before 2022-11-02)
- index your pages
Creating the Index
Indexing media
Copy the elasticsearch.conf.example
included in this plugin's conf directory into /conf/elasticsearch.conf
. The defaults should be fine for typical Linux servers. They include some popular file extensions and point to tools for extracting text from them, either as UNIX commands or a URL of a public Apache Tika server.
You can use the tools provided by ElasticSearch to create the index or simply run the provided command line tool to do so:
./bin/plugin.php elasticsearch createindex
The name of the index is determined by the configuration.
Re-creating the index
Sometimes it is necessary to throw away the old index and replace it with a new one. This can be done via the same DokuWiki script with an additional parameter:
./bin/plugin.php elasticsearch createindex --clear
Make sure to re-create your index after upgrading the plugin to 2022-11-02. This will update index structure and index your media.
Languages and fuzzy search
One of the main reasons for using a dedicated search engine is that it provides advanced features, such as fuzzy search. To enable it, the pages must be indexed using a linguistic analyzer in the appropriate language.
Only for versions before 2022-11-02: Make sure to create the language mapping using the CLI tool before filling the index. The below command is removed in latest versions of the plugin and all mapping is handled internally.
./bin/plugin.php elasticsearch createlangmapping
If you have configured multiple languages using the Translation plugin, they will be recognized as well.
By default all available translation are searched. Users can change the language selection in Advanced Search Tools.
You can also enable translation detection in the plugin configuration. The option is called detectTranslation
. When activated, the search will try to detect the current language context from the top namespace, and then set the language filter accordingly. For example, if the translation plugin is configured to handle the en es fr
namespaces and the user starts the search when browsing the page es:capítulos:tres
, the language filter will be automatically set to es
.
Index management
The pages will be indexed automatically when browsed, just like with the DokuWiki builtin mechanism. When a page is updated, its entry in the index will be updated as well.
You can also force indexing the whole Wiki at once using the CLI tool. This is recommended when you build the index for the first time or when you have made extensive changes (like moving pages or updating the ACLs).
./bin/plugin.php elasticsearch index
With versions starting with 2022-11-02 you can index pages or media separately:
./bin/plugin.php elasticsearch index --only=pages ./bin/plugin.php elasticsearch index --only=media
Other plugins
The tagging plugin integrates well with Elasticsearch. You can search for tags explicitly using #sometag
search terms. If any of the results are tagged, a tag filter will be added to Advanced Search Tools.
Development
Plugin integration
Elasticsearch emits several events that can be used by other plugins to put their own data into the search index. Take a look at the implementation tagging to see how those events can be used.
PLUGIN_ELASTICSEARCH_CREATEMAPPING
: Triggered when creating the index. Plugins may add their own fields and mappings via event data.PLUGIN_ELASTICSEARCH_INDEXPAGE
: While indexing a page, plugins can provide their own data.PLUGIN_ELASTICSEARCH_FILTERS
: Adds search configurations provided by plugins.PLUGIN_ELASTICSEARCH_SEARCHFIELDS
: Lets plugins add their own fields to the list of search fields included in the Elastic query.PLUGIN_ELASTICSEARCH_QUERY
: Lets plugins append their data to the query string.
Commit-Ticker
- Version upped (2022-11-10 23:50)
- use new DokuWiki logger (2022-11-10 14:14)
- Title may not be set for pages (2022-11-10 14:13)
- Version upped (2022-11-02 12:58)
- Reset vendor (2022-11-02 12:28)
- New field doctype works with not updated old index (2022-11-02 09:23)
- Plugins may no longer overwrite namespace filter (2022-10-27 20:35)
- Fix admin check in ACL part of search query (2022-10-27 18:59)
Releases:
- 2022-11-10 by splitbrainVersion upped
- 2022-11-02 by anndaVersion upped
- 2021-11-01: New field doctype works with not updated old index by anndaPreviously missing doctype caused all links to be media links
- 2021-06-10 by anndaRespect hidepages configuration
- 2021-06-09 by anndaAdd configuration option to disable DokuWiki's quick search
- 2021-06-07 by splitbrainVersion upped
- 2021-04-27 by splitbrainVersion upped
- 2021-04-21 by splitbrainVersion upped
ToDo/Wish List
- search a specific language
- exact match (non-fuzzy search)