Atelier organisé par Oxalide (Ludovic Piot) et Kernel 42 (Edouard Fajnzilberg) à destination des niveaux débutants et intermédiaire. Le point de vue du Syadmin et du Dev en un seul atelier et avoir une vision globale du fonctionnement et de l'usage d'Elastic Search.
3. Workshop #3 - Elasticsearch, an overview…
Les événements Oxalide…
• Objectif : présentation d’une thématique métier ou technique
• Tout public : 80 à 100 personnes
• Déroulé : 1 soir par trimestre de 18h à 21h
• Introduction de la thématique par un partenaire
• Tour de table avec des clients et non clients
• Echange convivial autour d’un apéritif dînatoire
• Objectif : présentation d’une technologie
• Réservé aux clients : public technique avec laptop – 30 personnes
• Déroulé : 1 matinée par trimestre de 9h à 13h
• Présentation de la technologie
• Tuto pour la configuration en ligne de commande
• Objectif : présentation d’un outil
• Réservé aux clients : 30 personnes
• Déroulé : 1 soir par trimestre de 18h à 21h
• Démonstration des fonctionnalités de l’outil
• Echange convivial autour de pizzas
Apérotech
Workshop
Pizza’n’Tools
4. Workshop #3 - Elasticsearch, an overview…
Les speakers…
Edouard Fajnzilberg
Directeur technique
@ kernel42
Ludovic Piot
Team Conseil / Architecture / DevOps
@ Oxalide
@lpiot
5. Introduction
Hands-on #1
découverte d’un cluster de 3 nœuds
Comment ça marche ?
Ecosystème
Hands-on #2
découverte de Marvel & Kibana
Questions & réponses ?
1
3
2
4
5
6
8. Introduction
Les principaux usages
recherche full text instantanée
recherche à la Google
permissif aux variantes
orthographiques
recherche performante sur des
milliers d’enregistrements
recherche pas limitée à des
champs définis
9. Introduction
Les principaux usages
recherche sur un critère fixe
recherche sur élément de liste
dynamique
recherche sur un périmètre
trier les résultats
limiter le nombre de résultats
retournés
paginer les résultats retournés
récupérer le nombre de résultats
restituer des résultats composites
14. Hands-on #1
API REST
verbe HTTP Type de ressources Exemple
GET
Documents
/twitter/tweet/AVNXnwSH24f3KF5HzrfR?pretty
PUT / POST
/twitter/tweet/AVNXnwSH24f3KF5HzrfR/_create
/twitter/tweet/AVNXnwSH24f3KF5HzrfR?version=1
/twitter/tweet/AVNXnwSH24f3KF5HzrfR?version=5&version_type=external
DELETE /twitter/tweet/AVNXnwSH24f3KF5HzrfR
POST Recherche
/twitter/tweet/_search
/twitter/_search
/_search
GET
Metadonnées
/twitter/_status
/_cluster/status | state | health | settings
/nodes | index/_stats
/_stats
/_search
/_cat
POST /_shutdown (supprimé en v2.x)
http://host:port/[index]/[type]/[_action/id] : remember where / what / which
16. Hands-on #1
Configuration du cluster
Script de démarrage Fichier de configuration
$ cat …/config/elasticsearch.yml
# Use a descriptive name for your cluster:
cluster.name: elastic-wkshop
# Use a descriptive name for the node:
node.name: elastic-wkshop-1
# Path to directory where to store the data:
path.data: /es/data
# Path to log files:
path.logs: /es/logs
# Lock the memory on startup:
bootstrap.mlockall: true
# Set the bind address to a specific IP (IPv4 or IPv6):
network.host: 172.31.23.121
# Set a custom port for HTTP:
http.port: 9200
# Pass an initial list of hosts to perform discovery when new node is started:
discovery.zen.ping.unicast.hosts: ["elastic-wkshop-
1", "elastic-wkshop-2", "elastic-wkshop-3"]
# Prevent the "split brain" by configuring the majority of nodes (total number
of nodes / 2 + 1):
discovery.zen.minimum_master_nodes: 2
$ cat …/bin/elasticsearch
ES_JAVA_OPTS="-Xms8192m -
Xmx8192m"
ES_HEAP_SIZE="8g"
18. Comment ça marche ?
Terminologie
Relational database ElasticSearch
database index
table type
row document
column field
schema mapping
tablespace / datafile / partition primary shard
SQL Query DSL
19. Comment ça marche ?
Principe de fonctionnement d’un index inversé
par ciel clair, les
oiseaux chantent
les oiseaux volent
dans le ciel
l’avion bondit vers
le ciel, tel un oiseau
Mot Localisation Position
ciel
0 0
1 2
2 2
clair 0 1
oiseau
0 2
1 0
2 3
chanter 0 4
voler 1 2
avion 2 1
bondir 2 2
20. Comment ça marche ?
Moteur de recherche et d’indexation
document
cleanup tokenize
stop wordstransform
Puisque l’indexation procède à ces transformations,
la recherche doit faire de même !
21. Comment ça marche ?
Segments
un index inversé par champ
segment immutable
consolidation des segments au fil de l’
eau
22. Système distribué
Nœuds du cluster
Primary shard
Replicas
Master nodes
Data nodes
Client nodes
Shard routing
Quorum
24. Comment ça marche ?
Mapping
Principes
PUT /[index]/_mapping
Mapping par défaut : {“_default_”: {}}
Dans un même index, tous les champs
du même nom DOIVENT avoir le même
mapping même si ils appartiennent à
des types différents
Exemple
{
"twitter": {
"mappings": {
"tweet": {
"properties": {
"date": {
"type": "date",
"format": "yyyy-MM-dd"
},
"text": {
"type": "string",
"index": "analyzed"
},
"user_id": {
"type": "long"
}
}
}
}
}
}
25. Comment ça marche ?
Mapping
Dynamic mapping
Dynamic Field Mapping
Exemple
PUT /twitter
{
"mappings": {
"tweet": {
"dynamic": "true|false|strict",
"date_detection": false
}
}
}
27. Comment ça marche ?
Mapping
Dynamic Mapping
Index Template
Exemple
PUT /_template/template_twitter
{
"template" : "twitter-*",
"settings" : {
"number_of_shards" : 1
},
"mappings" : {
"tweet" : {
[...]
}
}
}
28. Comment ça marche ?
Mapping
Mise à jour
On peut ajouter un nouveau field
On ne peut pas changer un field existant
Solution
On ne peut pas supprimer un mapping
(2.x)
Créer un nouvel index et tout ré-indexer :
Scroll Query + Bulk API
Alias d’index :
● index_v1
● index_v2
● index_v3
index => index_v3
PUT /[index]/_alias/[alias]