MediaWiki:SearchEngine

From wiki
Revision as of 21:28, 3 February 2025 by Hdridder (talk | contribs) (Hdridder moved page SearchEngine to MediaWiki:SearchEngine without leaving a redirect)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

CirrusSearch is a search extension that supports more complex search phrases. It uses ElasticSearch to store data.

ElasticSearch Install

For installation on mediawiki 1.35:

  • Install java8 and elasticsearch 6.8.23
  • Install the Elastica and CirrusSearch (use the same version as your MediaWiki version) extensions [1]
  • Follow instructions in ./extentions/CirrusSearch/README

MediaWiki LocalSettings

    • Add this to LocalSettings.php
wfLoadExtension( 'Elastica' );
wfLoadExtension( 'CirrusSearch' );
$wgDisableSearchUpdate = true;
  • php7.4 ./extensions/CirrusSearch/maintenance/UpdateSearchIndexConfig.php
  • Remove $wgDisableSearchUpdate = true from LocalSettings.php
  • php7.4 ./extensions/CirrusSearch/maintenance/ForceSearchIndex.php --skipLinks --indexOnSkip
  • php7.4 ./extensions/CirrusSearch/maintenance/ForceSearchIndex.php --skipParse
  • Edit LocalSettings.php to have $wgSearchType = 'CirrusSearch';

Check Special:Version to see if all is installed

To verify CirrusSearch is used add '&cirrusDumpQuery' to a search URL. A json-string will be shown.

ElastichSearch Tips

Remote ElasticSearch server

If ElasticSearch is on another server as the webserver you have to edit /etc/elasticsearch/elasticsearch.yml to listen to the outside address

network.host: <outside IP address>

Start/Stop script

For automatic start/stop I created /etc/init.d/elasticsearch like

#!/bin/sh
# kFreeBSD do not accept scripts as interpreters, using #!/bin/sh and sourcing.
if [ true != "$INIT_D_SCRIPT_SOURCED" ] ; then
    set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /lib/init/init-d-script
fi
### BEGIN INIT INFO
# Provides:          elasticsearch
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start ElastichSearch deamon
# Description:       Start ElastichSearch deamon
#                    This script starts a
#                    single forking daemon capable of writing a pid
#                    file.  
### END INIT INFO

# Author: Hans de Ridder <hans@deridder.it>
#

if [ `id -nu` != 'elasticsearch' ]
then
 su elasticsearch $0 $*
 exit
fi 

DESC="ElasticSearch engine"
DAEMON="/opt/elasticsearch/bin/elasticsearch"
DAEMON_ARGS="-d"

Now you can start by service elasticsearch start. Stopping is not implemented in this script.

In /etc/rc5.d do ln -s ../init.d/elasticsearch S02elasticsearch

Troubleshooting

curl http://localhost:9200/_aliases?pretty=true
List the indexes in elasticsearch
curl -XDELETE http://localhost:9200/<indexname>*/
Remove all indexes where name starts with <indexname>