DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:elasticsearch

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
plugin:elasticsearch [2019-09-12 21:22] – http://github to https://github Aleksandrplugin:elasticsearch [2024-02-15 12:01] (current) Aleksandr
Line 2: Line 2:
  
 ---- plugin ---- ---- plugin ----
-description: Integrate Elasticsearch engine+description: Integrate an external Elasticsearch engine into DokuWiki
 author     : Andreas Gohr, Anna Dabrowska  author     : Andreas Gohr, Anna Dabrowska 
 email      : dokuwiki@cosmocode.de  email      : dokuwiki@cosmocode.de 
-type       : action +type       : action, cli 
-lastupdate : 2019-07-31 +lastupdate : 2023-12-20 
-compatible : Greebo+compatible : Greebo, Hogfather, Igor, Jack Jackrum, Kaos
 depends    :  depends    : 
 conflicts  conflicts 
-similar    : +similar    : docsearch, searchtext
 tags       : search tags       : search
  
Line 23: Line 23:
 ===== Installation ===== ===== Installation =====
  
-[[https://www.cosmocode.de/en/open-source/dokuwiki-plugins/|{{ http://cosmocode.de/static/img/dokuwiki/dwplugins.png?recache|A CosmoCode Plugin}}]]+[[https://www.cosmocode.de/en/open-source/dokuwiki-plugins/|{{ https://www.cosmocode.de/static/img/dokuwiki/dwplugins.png?recache|A CosmoCode Plugin}}]]
  
 :!: **External requirements:** This plugin requires the following additional components that must be installed separately:  :!: **External requirements:** This plugin requires the following additional components that must be installed separately: 
-  * [[https://www.elastic.co/products/elasticsearch|Elasticsearch]] instance (latest supported version 7.1)+  * [[https://www.elastic.co/products/elasticsearch|Elasticsearch]] instance (latest tested version 8.11)
  
-Install the plugin using the [[plugin:plugin|Plugin Manager]] and the download URL above, which points to latest version of the plugin. Refer to [[:Plugins]] on how to install plugins manually.+Download and install the plugin using the [[plugin:extension|Extension Manager]]. Refer to [[:Plugins]] on how to install plugins manually.
  
 Configure and setup the plugin as outlined under [[#Configuration]] below. Configure and setup the plugin as outlined under [[#Configuration]] below.
Line 34: Line 34:
 ===== Examples/Usage ===== ===== Examples/Usage =====
  
-Once installed, the plugin will automatically react on the ?do=search action, replacing DokuWiki's builtin search. +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 [[acl|access rights]] are respected, so users will only find pages for which they have at least read privileges. All [[acl|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. +You can use the Advanced Search Tools to filter the results by namespace and date of the last modification. With [[plugin:tagging|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 [[plugin:text|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 ===== ===== Configuration and Settings =====
  
-To integrate this plugin, you will need to dp some configuration and run a few commands on the command line. +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 [[plugin:config|Configuration Settings]]   - enter the configuration of your Elasticsearch server in the [[plugin:config|Configuration Settings]]
 +  - optional: if your ES instance has security enabled (default setting since 8.0), enter the authentication username and password in [[plugin:config|Configuration Settings]]
 +  - copy and adjust a sample configuration for media indexing
   - create the Index   - create the Index
-  - create the Language Mappings 
   - index your pages   - index your pages
  
 ==== Creating the Index ==== ==== 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: You can use the tools provided by ElasticSearch to create the index or simply run the provided command line tool to do so:
Line 59: Line 66:
 The name of the index is determined by the configuration. The name of the index is determined by the configuration.
  
-==== Languages and fuzzy search ====+=== Re-creating the index ===
  
-One of the main reasons for using dedicated search engine is that it provides advanced features, such as fuzzy searchTo enable it, the pages must be indexed using a linguistic analyzer in the appropriate language. Make sure to create the language mapping using the CLI tool **before** filling the index.+Sometimes it is necessary to throw away the old index and replace it with new oneThis can be done via the same DokuWiki script with an additional parameter:
  
 <code> <code>
-./bin/plugin.php elasticsearch createlangmapping+./bin/plugin.php elasticsearch createindex --clear
 </code> </code>
  
-If you have configured multiple languages using the [[plugin:translation|Translation plugin]], they will be mapped as well.+:!: Make sure to re-create your index after upgrading the plugin to 2022-11-02. This will update index structure and index your media.
  
-At present there is no special filter that would let the user search in a particular language onlyHoweverit is possible to filter the results by language namespaces.+==== 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
 + 
 +If you have configured multiple languages using the [[plugin:translation|Translation plugin]], they will be recognized. 
 + 
 +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 accordinglyFor exampleif 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 ==== ==== Index management ====
Line 80: Line 95:
 ./bin/plugin.php elasticsearch index ./bin/plugin.php elasticsearch index
 </code> </code>
 +
 +You can index pages or media separately:
 +
 +<code>
 +./bin/plugin.php elasticsearch index --only=pages
 +./bin/plugin.php elasticsearch index --only=media
 +</code>
 +
 +
 +===== Other plugins =====
 +
 +The [[plugin:tagging|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 ===== ===== 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 [[plugin:tagging|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 ==== ==== Commit-Ticker ====
Line 94: Line 131:
   * search a specific language   * search a specific language
   * exact match (non-fuzzy search)   * exact match (non-fuzzy search)
-  * integration of the [[plugin:tagging]] plugin; tagged pages are shown on the results page but this bypasses Elasticsearch 
- 
  
plugin/elasticsearch.1568316141.txt.gz · Last modified: 2019-09-12 21:22 by Aleksandr

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki