Aujourd’hui nous allons implementer elasticsearch pour remplacer le moteur de recherche natif de Magento.
Une première partie concernera la partie installation et configuration du module Magento. La deuxième partie traitera de l’installation coté serveur debian.
Pourquoi Elasticsearch?
La problématique qui s’est posée à nous était la suivante : « Nous souhaitons une pondération sur les champs de recherche. Le nom du produit doit avoir un poids supérieur à celui de la description du produit dans l’ordre d’affichage des produits dans la page de résultats de recherche ».
Le module elasticsearch permet la pondération sur les attributs Magento!
2ème Partie : Installation du moteur sur serveur *nix
Pre requis
- Jdk version6 installé minimum
Vérifier avec la commande java -version
qui doit vous retourner
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)
- curl
Vérifier avec la commande curl
qui doit vous retourner
curl: try 'curl --help' or 'curl --manual' for more information
Ajout du dépôt
Pour des questions de maintenabilité et de mise à jour de sécurité des paquets il est toujours préférable de choisir un dépôt officiel apt. L’equipe d’ elasticsearch fait bien les choses car ils disposent d’un depot pour l’utilitaire apt.
- Télécharger et installer la public key du dépôt.
wget -O - http://packages.elasticsearch.org/GPG-KEY-elasticsearch | apt-key add -
- Ajouter la ligne ci-dessous à votre fichier /etc/apt/sources.list pour activer le dépot
deb http://packages.elasticsearch.org/elasticsearch/1.0/debian stable main
Installation
- Lancer
apt-get update
pour mise à jour des dépots - Lancer
apt-get install elasticsearch
pour installation- Le paquet créé un nouveau user elasticsearch, un nouveau groupe elasticsearch
A la fin de l’installation elasticsearch n’est pas lancé.
Vérification du bon fonctionnement
Pour lancer elasticsearch, taper la commande
sudo /etc/init.d/elasticsearch start
Par défaut le moteur est monté sur le port 9200. Il y a évidement possibilité de le changer dans le fichier de conf /etc/elasticsearch/elasticsearch.yml
Pour vérifier, taper la commande
curl -X GET http://localhost:9200/
Le retour doit être un format json
{
"status" : 200,
"name" : "Barnacle",
"version" : {
"number" : "1.0.2",
"build_hash" : "4fc0da7f4473021f274d4bc8e1f9e90fd3b4f55a",
"build_timestamp" : "2014-03-25T15:41:15Z",
"build_snapshot" : false,
"lucene_version" : "4.6"
},
"tagline" : "You Know, for Search"
}
Et voilà…
ENGLISH
Today we’ll replace native magento search engine by elasticsearch.
The first part will show you how to install and setup the magento module then how to install elasticsearch engine on debian server in the second part.
Why Elasticsearch?
The problem that arose to us was : « We want a weighting on Magento search fields. Product name weighting must be higher than the product description in the product display order on search results page »
Elascticsearch module allows weighting on Magento product attributes!
2ème Partie : Elasticsearch engine installtion on *nix server
Pre requisite
- Jdk version6 installed at least
please verify with this command java -version
response should be
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)
- curl
please verify with this command curl
response should be
curl: try 'curl --help' or 'curl --manual' for more information
Adding repository
It is always better to choose an official apt repository for maintainability and security matters. Elasticsearch‘s team does things nicely as they provide a offical one. Let’s add it to our server!
- Download and install the repository public key
wget -O - http://packages.elasticsearch.org/GPG-KEY-elasticsearch | apt-key add -
- add line below on your /etc/apt/sources.list to activate the repository
deb http://packages.elasticsearch.org/elasticsearch/1.0/debian stable main
Installing
- Run
apt-get update
for repository update - Run
apt-get install elasticsearch
for installation- Le paquet créé un nouveau user elasticsearch, un nouveau groupe elasticsearch
At the end of the install process elasticsearch is not running
Running and Verifiying
To run it, run the command
sudo /etc/init.d/elasticsearch start
It runs by default on port 9200. You can change by editing the config file /etc/elasticsearch/elasticsearch.yml
To verify, run the command below
curl -X GET http://localhost:9200/
In response you have a json format
{
"status" : 200,
"name" : "Barnacle",
"version" : {
"number" : "1.0.2",
"build_hash" : "4fc0da7f4473021f274d4bc8e1f9e90fd3b4f55a",
"build_timestamp" : "2014-03-25T15:41:15Z",
"build_snapshot" : false,
"lucene_version" : "4.6"
},
"tagline" : "You Know, for Search"
}
And done. Enjoy…