Extension:CirrusSearch

The CirrusSearch extension implements searching for MediaWiki using Elasticsearch.

This page is for installation.

After the install is working, see  for usage.

Project goals

 * No native dependencies that would make this difficult to install


 * The only dependencies are pure-PHP MediaWiki extensions and Elasticsearch itself


 * Provide a near-real-time search index for wiki pages that's extendable by other MediaWiki extensions


 * Provide all of the query options  has given users, and more

Dependencies

 * PHP and cURL


 * In addition to the page>Manual:Installation_requirements#PHP|standard MediaWiki requirements for PHP, CirrusSearch requires PHP to be compiled with [https://secure.php.net/intro.curl cURL] support.
 * Elasticsearch


 * You will need to [https://www.elastic.co/guide/en/elasticsearch/reference/current/install-elasticsearch.html install Elasticsearch].

Take note that a Java installation like [https://openjdk.java.net OpenJDK] is needed in addition.




 * Elastica is a PHP library to talk to Elasticsearch. Install Elastica per the ref>#Elastica|instructions below.


 * Other


 * Due to the actual handling of jobs by the CirrusSearch extension, it's advisable to redis>Redis#Job queue|set up jobs in redis to prevent messages like Notice: unserialize: Error at offset 64870 of 65535 bytes in JobQueueDB.php and subsequent errors like Unsupported operand types</>. See <tvar|1></>.

Even though the instructions below tell you to only run Composer when installing from git, it may be necessary to issue it anyway in order to install all PHP dependencies.

Upgrading
Please follow the upgrade instructions in the CirrusSearch <tvar|gitinstr></> file.

Configuration
The configuration options of CirrusSearch are documented at the <tvar|gitconfig></> file, and also in the <tvar|gitcirrus></> file.

See also documentation on 1>Extension:CirrusSearch/Profiles</>|CirrusSearch configuration profiles.

Hooks
CirrusSearch extension defines a number of hooks that other extensions can make use of to extend the core schema and modify documents.

The following hooks are available:


 * - allows to hook into the configuration for analysis
 * - allows configuration of the mapping of fields
 * - allows extensions to modify ElasticSearch document produced from a page
 * - allows extensions to process incoming and outgoing links for the document
 * - called when a batch of pages has been indexed
 * - allows extensions to add query parser features
 * - allows extensions to define rescore builder functions

API
CirrusSearch features can be used in API queries. Searching happens via the normal search API, <tvar|apisearch> </>; you can use CirrusSearch-specific features, such as the  special prefix to find pages related to urlcurie>:en:Marie Curie</>|Marie Curie and urlradium>:en:radium</>|radium: [<tvar|urlquery>https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch=morelike:Marie_Curie%7Cradium&srlimit=10&srprop=size&formatversion=2</> api.php?action=query&list=search&srsearch=morelike:Marie_Curie%7Cradium&srlimit=10&srprop=size&formatversion=2]

Custom APIs and parameters are provided for querying CirrusSearch configuration and debug information:


 * module: [<tvar|url>https://en.wikipedia.org/wiki/2014?action=cirrusdump</> 2014?action=cirrusdump]
 * parameter to url>:en:Special:Search</>|Special:Search or search API queries: <tvar|query>https://en.wikipedia.org/wiki/Special:Search/cat%20dog%20chicken?cirrusDumpQuery</>
 * parameter to url>:en:Special:Search</>|Special:Search or search API queries: <tvar|query>https://en.wikipedia.org/wiki/Special:Search/cat%20dog%20chicken?cirrusDumpResult</>
 * An additional parameter,, can be passed with   to have the Lucene explanation of the score included with the result dump: <tvar|url>https://en.wikipedia.org/wiki/Special:Search/cat%20dog%20chicken?cirrusDumpResult&cirrusExplain</> It can also be used to get the explanation in a human-readable format, by giving it one of the values  ,   or  , such as: <tvar|url2>https://en.wikipedia.org/wiki/Special:Search/cat%20dog%20chicken?cirrusDumpResult&cirrusExplain=pretty</>
 * , ,   modules to obtain dump from the CirrusSearch setup: [<tvar|url>https://en.wikipedia.org/w/api.php?action=cirrus-config-dump&formatversion=2</> api.php?action=cirrus-config-dump&formatversion=2]

Local development
Elastic Search service can be run with the Vagrant role and MediaWiki Vagrant.

For Docker, you can use a command like <tvar|command> </>.

Then follow the installation and configuration directions.

If your web host is in a container you'll want to make sure the above container is on the same network, and in LocalSettings.php you will want to reference  as the host name.

This will not have the WMF plugins but can be sufficient for basic testing.