Jump to content
  • 0

Restore ElasticSearch functionality



A couple months ago, had a mediawiki server with 3 wikis running on it dumped in my lap to support. The search box was using CirrusSearch and ElasticSearch / Elastica to generate results, but that was recently broken when the security team did some sort of log4j remediation. All searches would return "An error has occurred while searching: We could not complete your search due to a temporary problem. Please try again later."

So, I removed most traces of CirrusSearch / ElasticSearch and then had the bare-bones MediaWiki search working and of course no longer received the above error. Our server was running back-level MediaWiki (1.30), so I just brought the software up to nearly the latest versions.

Centos 7.3.1611

Product Version
MediaWiki 1.37.2
PHP 7.4.28 (apache2handler)
MySQL 5.7.20





6.5.4 (70b9a7e) 05:55, 16 March 2022

Elasticsearch-powered search for MediaWiki


6.1.3 (c2b259b) 05:46, 19 January 2022

Base Elasticsearch functionality for other extensions by providing Elastica library

# yum list installed|grep elastic
elasticsearch.noarch              6.8.23-1                      @elasticsearch6
elasticsearch-curator.x86_64      5.4.1-1                       installed

I reenabled CirrusSearch and Elastica in LocalSettings.php, and my Version page shows them as loaded, but while I'm still not getting errors, the search results don't seem like they are enhanced in any way. How can I confirm whether or not I'm actually getting results from ElasticSearch instead of the default built-in search? 

I suspect I already have my answer in that my attempt to regenerate my elasticsearch index fails with the response below. So I guess the real question is how do I fix ElasticSearch for my wikis?

# php /data/www/html/wiki/extensions/CirrusSearch/maintenance/UpdateSearchIndexConfig.php
Updating cluster ...
indexing namespaces...
Elastica\Exception\Connection\HttpException from line 190 of /data/www/html/wiki/extensions/Elastica/vendor/ruflin/elastica/lib/Elastica/Transport/Http.php: Couldn't connect to host, Elasticsearch down?
#0 /data/www/html/wiki/extensions/Elastica/vendor/ruflin/elastica/lib/Elastica/Request.php(194): Elastica\Transport\Http->exec()
#1 /data/www/html/wiki/extensions/Elastica/vendor/ruflin/elastica/lib/Elastica/Client.php(689): Elastica\Request->send()
#2 /data/www/html/wiki/extensions/Elastica/vendor/ruflin/elastica/lib/Elastica/Client.php(721): Elastica\Client->request()
#3 /data/www/html/wiki/extensions/Elastica/vendor/ruflin/elastica/lib/Elastica/Index.php(586): Elastica\Client->requestEndpoint()
#4 /data/www/html/wiki/extensions/Elastica/vendor/ruflin/elastica/lib/Elastica/Index.php(330): Elastica\Index->requestEndpoint()
#5 /data/www/html/wiki/extensions/CirrusSearch/includes/MetaStore/MetaStoreIndex.php(501): Elastica\Index->exists()
#6 /data/www/html/wiki/extensions/CirrusSearch/includes/MetaStore/MetaStoreIndex.php(165): CirrusSearch\MetaStore\MetaStoreIndex::cirrusReady()
#7 /data/www/html/wiki/extensions/CirrusSearch/includes/Maintenance/Maintenance.php(221): CirrusSearch\MetaStore\MetaStoreIndex->createIfNecessary()
#8 /data/www/html/wiki/extensions/CirrusSearch/maintenance/IndexNamespaces.php(36): CirrusSearch\Maintenance\Maintenance->maybeCreateMetastore()
#9 /data/www/html/wiki/extensions/CirrusSearch/maintenance/UpdateSearchIndexConfig.php(65): CirrusSearch\Maintenance\IndexNamespaces->execute()
#10 /data/www/html/wiki/maintenance/doMaintenance.php(108): CirrusSearch\Maintenance\UpdateSearchIndexConfig->execute()
#11 /data/www/html/wiki/extensions/CirrusSearch/maintenance/UpdateSearchIndexConfig.php(103): require_once('/data/www/html/...')
#12 {main}

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

You'll likely need to rebuild all of the elasticsearch indexes, so following the install/upgrade guide from the beginning should be helpful with that. That error indicates that communication can't be established between the wiki and the ES server, so I'd check firewall, etc. for that

Link to comment
Share on other sites

  • 0

Yes, UpdateSearchIndexConfig.php failing means either your ES server isn't running/healthy, or CS doesn't know where to find it. If you haven't already you need to set CS configuration parameters in LocalSettings:

$wgCirrusSearchServers = [ 'NAMEOFESSERVER' ];
### Server name can also be an IP or a container name
$wgSearchType = 'CirrusSearch';
### This tells Mediawiki to use CS for searches

A good connection to your ES server will give you script results like:

indexing namespaces...
        Indexing namespaces...done
		content index...
        Fetching Elasticsearch version...6.8.20...ok
        Scanning available plugins...none
        Picking analyzer...english
        Inferring index identifier...minerva_content_first
                Validating number of shards...ok
                Validating replica range...ok
                Validating shard allocation settings...done
                Validating max shards per node...ok
        Validating analyzers...ok
        Validating mappings...
                Validating mapping...ok
        Validating aliases...
                Validating minerva_content alias...ok
                Validating minerva alias...ok
                Updating tracking indexes...done

The best way to confirm if you're getting CS search results is to append '&cirrusDumpQuery' to the search URL for a data-dump in json-format. If you get a json, it's using Cirrus, if you just get the normal search page it isn't.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.