Difference between revisions of "Elasticsearch"

From Freephile Wiki
Jump to navigation Jump to search
(Created page with "Elasticsearch is a distributed RESTful search engine built for the cloud. Features include: * Distributed and Highly Available Search Engine. ** Each index is fully sharded w...")
 
Line 1: Line 1:
 +
This site uses Elasticsearch for it's search functionality under the hood.
 +
{{Feature
 +
|explains= Search
 +
|description= This site uses Elasticsearch for the best possible search experience [[File:System-search.svg|link=Search|thumb|64px]]
 +
|notes=
 +
|tests=
 +
|examples=
 +
}}
 +
 +
 +
== About ==
 
Elasticsearch is a distributed RESTful search engine built for the cloud. Features include:
 
Elasticsearch is a distributed RESTful search engine built for the cloud. Features include:
  
Line 25: Line 36:
 
* Open Source under the Apache License, version 2 ("ALv2")
 
* Open Source under the Apache License, version 2 ("ALv2")
  
This site uses Elastic Search for it's search functionality under the hood.
+
== Video ==
 +
* [https://vimeo.com/136326424 Building Elasticsearch: From Idea to {code} to Adoption] The back side of a napkin, a pen, and a few beverages are often the ingredients that yield good ideas. Elasticsearch had a different origin. It started with a need for a simple search box for a collection of recipes. '''Shay Banon''', creator of Elasticsearch and CTO at Elastic
 +
* https://www.elastic.co/about
 +
 
 +
== Elasticsearch for MediaWiki ==
 +
To improve the out-of-the-box search experience with MediaWiki, you should install the [[mw:Extension:CirrusSearch]].  CirrusSearch is just a connector to the Elasticsearch engine.  Thus, to use CirrusSearch, first install the [[Elasticsearch]] system (you can use [https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-repositories.html the repositories for that]). 
 +
 
 +
This system has three components: Elastica, CirrusSearch, and Elasticsearch.
 +
; Elastica : Elastica is a MediaWiki extension that provides the library to interface with Elasticsearch. It wraps the [https://github.com/ruflin/Elastica Elastica] library. It has no configuration.
 +
; CirrusSearch : CirrusSearch is a MediaWiki extension that provides search support backed by Elasticsearch.
 +
; Elasticsearch : is a Java application, so you need [[Java]] installed as well.  At the time of this writing, there is a version mismatch.  Elasticsearch is at version 2.1.1 in the repositories, but CirrusSearch is only compatible with the older 1.7 version.
 +
 
 +
== Installation ==
 +
Here's a quick example of how we got all the parts installed on an [[Ubuntu]] server.
 +
<source lang="bash">
 +
# is the curl extension to PHP installed?
 +
php -i |grep -C2 curl
 +
# no curl?
 +
sudo apt-get install php5-curl
 +
pushd extensions
 +
java -version
 +
# no java
 +
sudo apt-get install default-jre
 +
# need the jdk
 +
sudo apt-get install default-jdk
 +
# add JAVA_HOME to /etc/environment
 +
sudo update-alternatives --config java
 +
echo 'JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java' |sudo tee -a /etc/environment
 +
source /etc/environment
 +
echo $JAVA_HOME
 +
wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
 +
echo "deb http://packages.elastic.co/elasticsearch/2.x/debian stable main" | sudo tee -a /etc/apt/sources.list.d/elasticsearch-2.x.list
 +
#### don't do this because 2.1.1 is too new
 +
#### sudo apt-get update && sudo apt-get install elasticsearch
 +
#### get the 1.7.x version and install that
 +
wget https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.7.4.deb
 +
sudo dpkg -i elasticsearch-1.7.4.deb
 +
echo PATH=$PATH:/usr/share/elasticsearch/bin/ | sudo tee -a /etc/environment
 +
source /etc/environment
 +
which elasticsearch
 +
sudo service elasticsearch start
 +
# check with curl (see below)
 +
# using SysV init
 +
sudo update-rc.d elasticsearch defaults 95 10
 +
git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/CirrusSearch.git
 +
git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/Elastica.git
 +
cd Elastica
 +
composer install
 +
# load Special:Version to check
 +
sudo -u www-data php ./w/extensions/CirrusSearch/maintenance/updateSearchIndexConfig.php
 +
sudo -u www-data php  /var/www/freephile.com/www/w/extensions/CirrusSearch/maintenance/forceSearchIndex.php --skipLinks --indexOnSkip
 +
sudo -u www-data php  /var/www/freephile.com/www/w/extensions/CirrusSearch/maintenance/forceSearchIndex.php --skipParse
 +
</source>
 +
 
 +
Checking if elasticsearch is running
 +
<source lang="bash">
 +
curl -X GET http://localhost:9200/
 +
</source>
 +
<source lang="javascript">
 +
{
 +
  "name" : "Carmella Unuscione",
 +
  "cluster_name" : "elasticsearch",
 +
  "version" : {
 +
    "number" : "2.1.1",
 +
    "build_hash" : "40e2c53a6b6c2972b3d13846e450e66f4375bd71",
 +
    "build_timestamp" : "2015-12-15T13:05:55Z",
 +
    "build_snapshot" : false,
 +
    "lucene_version" : "5.3.1"
 +
  },
 +
  "tagline" : "You Know, for Search"
 +
}
 +
// second time around with the older version installed
 +
{
 +
  "status" : 200,
 +
  "name" : "Richard Rider",
 +
  "cluster_name" : "elasticsearch",
 +
  "version" : {
 +
    "number" : "1.7.4",
 +
    "build_hash" : "0d3159b9fc8bc8e367c5c40c09c2a57c0032b32e",
 +
    "build_timestamp" : "2015-12-15T11:25:18Z",
 +
    "build_snapshot" : false,
 +
    "lucene_version" : "4.10.4"
 +
  },
 +
  "tagline" : "You Know, for Search"
 +
}
 +
</source>
 +
 
 +
== Resources ==
 +
* https://phabricator.wikimedia.org/diffusion/ECIR/browse/master/CirrusSearch.php
 +
* https://git.wikimedia.org/blob/mediawiki%2Fextensions%2FCirrusSearch.git/HEAD/README
 +
* https://wikitech.wikimedia.org/wiki/Search
  
 
[[Category:Search]]
 
[[Category:Search]]

Revision as of 11:39, 30 January 2016