SlideShare une entreprise Scribd logo
Why

Elasticsearch
    rocks !
              AlpesJUG – 19 février 2013
Tanguy Leroux
●
    Consultant et Formateur @ Zenika
●
    Elasticsearch Addict


●
    @tlrx
●
    http://github.com/tlrx
●
    tlrx.dev@gmail.com
Un projet

  Open source
+ 700 forks +3500 watchers +100 commiters GitHub
                 Apache 2 License
Basé sur


Apache lucene
   Version 3.6.2, bientôt la 4.1
Une installation


ZERO CONFIG
Décompresser. Exécuter. Ça marche.
Orienté


document
    JSON
personne

{
    "nom"            : "Reinhardt",
    "prenom"         : "Jean Django",
    "date_naissance" : "1910-10-23"
}
film

{
    "titre"       : "Django Unchained",
    "genre"       : "western",
    "date_sortie" : "2013-01-16"
}
Elasticsearch / SGBD

 Index     → Base de données
  Type     →       Table
Document   →       Row
  Field    →      Column
Mapping    →     Schema
Elasticsearch est


    SCHEMA LeSS
La structure des documents peut évoluer avec le temps
Aujourd'hui

{
    "titre"        : "Django Unchained",
    "genre"      : "western",
    "date_sortie": "2013-01-16"
}
demain
{
    "titre"       :    "Django Unchained",
    "genre"       :    "western",
    "date_sortie" :    "2013-01-16",
    "realisateur" :    {
            "nom" :    "Tarantino",    "prenom" :      "Quentin"
    },
    "nb_entrees" :     3159385,
    "acteurs"     :    [
            {
               "nom"   :   "Foxx",        "prenom" :   "Jamie"
            },
            {
               "nom"   :   "Waltz",   "prenom" :   "Christoph"
            },
            {
               "nom"   :   "Tarantino",   "prenom" :   "Quentin"
            }
    ]
}
Recherche de « tarantino »
{
    "titre"       :    "Django Unchained",
    "genre"            : "western",
    "date_sortie" :    "2013-01-16",
    "realisateur" :    {
            "nom" :    "Tarantino",    "prenom" :      "Quentin"
    },
    "nb_entrees" :     3159385,
    "acteurs"     :    [
            {
               "nom"   :   "Foxx",        "prenom" :   "Jamie"
            },
            {
               "nom"   :   "Waltz",   "prenom" :   "Christoph"
            },
            {
               "nom"   :   "Tarantino",   "prenom" :   "Quentin"
            }
    ]
}
Recherche de « django »
                 film                           personne
{
    "titre" : "Django Unchained",
    "genre" : "western",
                                    {
    "date_sortie" : "2013-01-16",
       "realisateur" : {                "nom"      :   "Reinhardt",

         "nom" : "Tarantino",           "prenom"   :   "Jean Django",
         "prenom" : "Quentin"           "date_naissance" : "1910-10-23"
    },                              }
    "nb_entrees" : 3159385,
    "acteurs" : [...]
}
Un moteur de recherche


        restful
http://HOST:PORT/index(s)/type(s)/_action|id
           Méthodes HTTP: GET, PUT, POST, DELETE
Exemples
Indexer un document
       Put       http://HOST:PORT/mediatheque/film/1
       POSt      http://HOST:PORT/mediatheque/film/

Récupérer un document
       get       http://HOST:PORT/mediatheque/film/1

Supprimer un document
      delete     http://HOST:PORT/mediatheque/film/1

Créer un index
       post       http://HOST:PORT/mediatheque/musique

Rechercher
       get        http://HOST:PORT/mediatheque/film/_search?q=django
       get        http://HOST:PORT/_search?q=django
Un langage de requêtes


 Query dsl
match, field, query_string, bool, term,
   Fuzzy, match_all,more like this, geo,
           Range, wildcard, span,
                     ...
De nombreuses


    Facettes
terms, histogram, date histogram, range,
     Stats, geo distance, filter, query
                     ...
facette « terms »
curl -XGET 'localhost:9200/_search' -d '
{
    "query": {
        "match": {       "titre": "django hard" }
    },
    "facets": {
        "facet_genres": {
            "terms": {    "field": "genre"   }
        }
    }
}'
facette « terms »
{...
    "hits":{
         ...
    },
    "facets":{
         "facet_genres":{
               "_type":"terms",
               "missing":0,
               "total":2,
               "other":0,
               "terms":[
                   {"term":"western","count":1},
                   {"term":"action","count":1}
               ]
         }
    }
}
facette « terms »
{...
    "hits":{
         ...
    },
    "facets":{
         "facet_genres":{
               "_type":"terms",
               "missing":0,
               "total":2,
               "other":0,
               "terms":[
                   {"term":"western","count":1},
                   {"term":"action","count":1}
               ]
         }
    }
}
facette «histogramme»
curl -XGET 'localhost:9200/media/film_search' -d '
{
    "query": {
        "match_all": {}
    },
    "facets": {
        "facet_entrees": {
            "histogram": {
                "field": "nb_entrees",
                "interval": "1000000"
            }
        }
    }
}'
facette «histogramme»
{
    "hits": { … },
    "facets": {
        "facet_entrees": {
            "_type": "histogram",
            "entries": [
                 { "key": 1000000, "count": 1 },
                 { "key": 2000000, "count": 1 },
                 { "key": 3000000, "count": 1 }
            ]
        }
    }
}
facette «histogramme»
{
    "hits": { … },
    "facets": {
        "facet_entrees": {
            "_type": "histogram",
            "entries": [
                 { "key": 1000000, "count": 1 },
                 { "key": 2000000, "count": 1 },
                 { "key": 3000000, "count": 1 }
            ]
        }
    }
}
Elasticsearch est


      distribué
Plusieurs nœuds communiquent en uni/multicast
               Node master, data, http
                         ...
Ils ont aussi pensé à la


supervision
Elasticsearch est


100 % Java
Mais aussi tout plein d'autres


       clients
Php, perl, scala, python, shell, ruby,.Net,
       Grails, play !, flume, clojure,
                 Puppet, chef,...
Un gros paquet de


    plugins
Plugin d'analyse, rivers, transport,
             Site, misc,
                  ...
Extraction de texte avec


Apache tika
L'indexation facilitée avec les


         rivers
Jdbc, Mongodb, couchdb, rabbitmq, activemq,
        Ldap, rss, twitter, wikipedia,
                      ...
Jdbc river plugin
curl -XPUT 'localhost:9200/_river/my_jdbc_river/_meta' -d '{
         "type" : "jdbc",
     "jdbc" : {
         "driver" : "com.mysql.jdbc.Driver",
         "url" : "jdbc:mysql://localhost:3306/test",
         "user" : "",
         "password" : "",
         "sql" : "select * from orders"
     }
}'
L'API

percolate
API percolate
curl -XPUT localhost:9200/_percolator/media/film_box_office -d '{
 "query": {
     "constant_score": {
         "filter": {
             "range": {
                 "nb_entrees": {
                     "from": "5000000", "include_lower": true
                 }
             }
         }
     }
 }
}'
API percolate
curl -XPOST 'localhost:9200/media/film/?percolate=*' -d '{
     "titre":"Hollywoo",
     "genre":"drame",
     "nb_entrees": 6000000
}'


{
     "ok":true,
     "_index":"media",
     "_type":"film",
     "_id":"70fc7FMWS8Sdxo733_5sWg",
     "_version":1,
     "matches":["film_box_office"]
}
Et aussi

Parent/child
  Warmers
   Slowlog
    Script
    Backup
      ...
Merci

  ?

Contenu connexe

PDF
Breizhcamp 2015 - Comment (ne pas réussir à) modéliser ses data dans elastics...
Bruno Bonnin
 
PDF
Lausanne JUG - Elasticsearch
David Pilato
 
PDF
Elasticsearch - Esme sudria
David Pilato
 
KEY
Elasticsearch - Montpellier JUG
David Pilato
 
PDF
Poitou charentes JUG - Elasticsearch
David Pilato
 
PDF
Hello mongo
CEDRIC DERUE
 
PDF
Introduction à Ruby
Jérémy Lecour
 
PDF
Paris data geek - Elasticsearch
David Pilato
 
Breizhcamp 2015 - Comment (ne pas réussir à) modéliser ses data dans elastics...
Bruno Bonnin
 
Lausanne JUG - Elasticsearch
David Pilato
 
Elasticsearch - Esme sudria
David Pilato
 
Elasticsearch - Montpellier JUG
David Pilato
 
Poitou charentes JUG - Elasticsearch
David Pilato
 
Hello mongo
CEDRIC DERUE
 
Introduction à Ruby
Jérémy Lecour
 
Paris data geek - Elasticsearch
David Pilato
 

En vedette (20)

PDF
Get Soaked - An In Depth Look At PHP Streams
Davey Shafik
 
PDF
Diving deep into twig
Matthias Noback
 
ODP
Elastic Searching With PHP
Lea Hänsenberger
 
PDF
Techniques d'accélération des pages web
Jean-Pierre Vincent
 
PDF
Automation using-phing
Rajat Pandit
 
ODP
PHP5.5 is Here
julien pauli
 
PPTX
Electrify your code with PHP Generators
Mark Baker
 
PDF
The quest for global design principles (SymfonyLive Berlin 2015)
Matthias Noback
 
PDF
Mocking Demystified
Marcello Duarte
 
PDF
Top tips my_sql_performance
afup Paris
 
PDF
Understanding Craftsmanship SwanseaCon2015
Marcello Duarte
 
PDF
Si le tdd est mort alors pratiquons une autopsie mix-it 2015
Bruno Boucard
 
PDF
Writing infinite scalability web applications with PHP and PostgreSQL
Gabriele Bartolini
 
PDF
L'ABC du BDD (Behavior Driven Development)
Arnauld Loyer
 
PDF
Behat 3.0 meetup (March)
Konstantin Kudryashov
 
PDF
TDD with PhpSpec - Lone Star PHP 2016
CiaranMcNulty
 
PDF
Performance serveur et apache
afup Paris
 
PDF
Caching on the Edge
Fabien Potencier
 
PDF
The Wonderful World of Symfony Components
Ryan Weaver
 
PDF
PHPSpec - the only Design Tool you need - 4Developers
Kacper Gunia
 
Get Soaked - An In Depth Look At PHP Streams
Davey Shafik
 
Diving deep into twig
Matthias Noback
 
Elastic Searching With PHP
Lea Hänsenberger
 
Techniques d'accélération des pages web
Jean-Pierre Vincent
 
Automation using-phing
Rajat Pandit
 
PHP5.5 is Here
julien pauli
 
Electrify your code with PHP Generators
Mark Baker
 
The quest for global design principles (SymfonyLive Berlin 2015)
Matthias Noback
 
Mocking Demystified
Marcello Duarte
 
Top tips my_sql_performance
afup Paris
 
Understanding Craftsmanship SwanseaCon2015
Marcello Duarte
 
Si le tdd est mort alors pratiquons une autopsie mix-it 2015
Bruno Boucard
 
Writing infinite scalability web applications with PHP and PostgreSQL
Gabriele Bartolini
 
L'ABC du BDD (Behavior Driven Development)
Arnauld Loyer
 
Behat 3.0 meetup (March)
Konstantin Kudryashov
 
TDD with PhpSpec - Lone Star PHP 2016
CiaranMcNulty
 
Performance serveur et apache
afup Paris
 
Caching on the Edge
Fabien Potencier
 
The Wonderful World of Symfony Components
Ryan Weaver
 
PHPSpec - the only Design Tool you need - 4Developers
Kacper Gunia
 
Publicité

Similaire à Why elasticsearch rocks! (11)

PDF
XebiCon'16 : Les requêtes avancées dans ElasticSearch Par Gérome Egron et I...
Publicis Sapient Engineering
 
PDF
MongoDB : la base NoSQL qui réinvente la gestion de données
SOAT
 
KEY
Hands on lab Elasticsearch
David Pilato
 
PDF
Construisez votre première application MongoDB
MongoDB
 
PDF
OpenData, LinkedData & SmartCities
deromemont
 
PDF
Présentation de ElasticSearch / Digital apéro du 12/11/2014
Silicon Comté
 
KEY
Elasticsearch - OSDC France 2012
David Pilato
 
KEY
Lyon JUG - Elasticsearch
David Pilato
 
PDF
De java à swift en 2 temps trois mouvements
Didier Plaindoux
 
PDF
Développement avec Java Micro Edition
Sylvain Wallez
 
PDF
Moteurs de recherche : un oeil sous le capot avec Elastic Search
Audrey Neveu
 
XebiCon'16 : Les requêtes avancées dans ElasticSearch Par Gérome Egron et I...
Publicis Sapient Engineering
 
MongoDB : la base NoSQL qui réinvente la gestion de données
SOAT
 
Hands on lab Elasticsearch
David Pilato
 
Construisez votre première application MongoDB
MongoDB
 
OpenData, LinkedData & SmartCities
deromemont
 
Présentation de ElasticSearch / Digital apéro du 12/11/2014
Silicon Comté
 
Elasticsearch - OSDC France 2012
David Pilato
 
Lyon JUG - Elasticsearch
David Pilato
 
De java à swift en 2 temps trois mouvements
Didier Plaindoux
 
Développement avec Java Micro Edition
Sylvain Wallez
 
Moteurs de recherche : un oeil sous le capot avec Elastic Search
Audrey Neveu
 
Publicité

Dernier (12)

PPTX
Soutanece Stage Pfe Développement Web et Multimédia
YassineMyara
 
PDF
CHAPITRE 5_Déplacement des données DBA.pdf
houcemswissi1
 
PDF
Katalog VRF Clivet vrf technology(1).pdf
MehfoozAli19
 
PPTX
voip architecture et installation de solution voip
samiraelazouzy
 
PDF
Google Remote Procedure Call Web Service
SOUFIANE MOUHTARAM
 
PDF
CHAPITRE1_Architecture du Serveur Oracle.pdf
houcemswissi1
 
PDF
Rapport de Stage Fin D’étude - Développement Web et Multimédia
YassineMyara
 
PDF
Communication entre les conteneurs docker dans diff réseaux
SOUFIANE MOUHTARAM
 
PDF
Circuit Breaker pattern avec Resilience4j
SOUFIANE MOUHTARAM
 
PDF
Présentation UCOPIA et ses fonctionnalités
ZakariaRAHOUI2
 
PDF
Généralités sur balisage (Tagging) en git
SOUFIANE MOUHTARAM
 
PDF
linkyfi presentation et ses fonctionnalité
ZakariaRAHOUI2
 
Soutanece Stage Pfe Développement Web et Multimédia
YassineMyara
 
CHAPITRE 5_Déplacement des données DBA.pdf
houcemswissi1
 
Katalog VRF Clivet vrf technology(1).pdf
MehfoozAli19
 
voip architecture et installation de solution voip
samiraelazouzy
 
Google Remote Procedure Call Web Service
SOUFIANE MOUHTARAM
 
CHAPITRE1_Architecture du Serveur Oracle.pdf
houcemswissi1
 
Rapport de Stage Fin D’étude - Développement Web et Multimédia
YassineMyara
 
Communication entre les conteneurs docker dans diff réseaux
SOUFIANE MOUHTARAM
 
Circuit Breaker pattern avec Resilience4j
SOUFIANE MOUHTARAM
 
Présentation UCOPIA et ses fonctionnalités
ZakariaRAHOUI2
 
Généralités sur balisage (Tagging) en git
SOUFIANE MOUHTARAM
 
linkyfi presentation et ses fonctionnalité
ZakariaRAHOUI2
 

Why elasticsearch rocks!

  • 1. Why Elasticsearch rocks ! AlpesJUG – 19 février 2013
  • 2. Tanguy Leroux ● Consultant et Formateur @ Zenika ● Elasticsearch Addict ● @tlrx ● http://github.com/tlrx ● [email protected]
  • 3. Un projet Open source + 700 forks +3500 watchers +100 commiters GitHub Apache 2 License
  • 4. Basé sur Apache lucene Version 3.6.2, bientôt la 4.1
  • 7. personne { "nom" : "Reinhardt", "prenom" : "Jean Django", "date_naissance" : "1910-10-23" }
  • 8. film { "titre" : "Django Unchained", "genre" : "western", "date_sortie" : "2013-01-16" }
  • 9. Elasticsearch / SGBD Index → Base de données Type → Table Document → Row Field → Column Mapping → Schema
  • 10. Elasticsearch est SCHEMA LeSS La structure des documents peut évoluer avec le temps
  • 11. Aujourd'hui { "titre" : "Django Unchained", "genre" : "western", "date_sortie": "2013-01-16" }
  • 12. demain { "titre" : "Django Unchained", "genre" : "western", "date_sortie" : "2013-01-16", "realisateur" : { "nom" : "Tarantino", "prenom" : "Quentin" }, "nb_entrees" : 3159385, "acteurs" : [ { "nom" : "Foxx", "prenom" : "Jamie" }, { "nom" : "Waltz", "prenom" : "Christoph" }, { "nom" : "Tarantino", "prenom" : "Quentin" } ] }
  • 13. Recherche de « tarantino » { "titre" : "Django Unchained", "genre" : "western", "date_sortie" : "2013-01-16", "realisateur" : { "nom" : "Tarantino", "prenom" : "Quentin" }, "nb_entrees" : 3159385, "acteurs" : [ { "nom" : "Foxx", "prenom" : "Jamie" }, { "nom" : "Waltz", "prenom" : "Christoph" }, { "nom" : "Tarantino", "prenom" : "Quentin" } ] }
  • 14. Recherche de « django » film personne { "titre" : "Django Unchained", "genre" : "western", { "date_sortie" : "2013-01-16", "realisateur" : { "nom" : "Reinhardt", "nom" : "Tarantino", "prenom" : "Jean Django", "prenom" : "Quentin" "date_naissance" : "1910-10-23" }, } "nb_entrees" : 3159385, "acteurs" : [...] }
  • 15. Un moteur de recherche restful http://HOST:PORT/index(s)/type(s)/_action|id Méthodes HTTP: GET, PUT, POST, DELETE
  • 16. Exemples Indexer un document Put http://HOST:PORT/mediatheque/film/1 POSt http://HOST:PORT/mediatheque/film/ Récupérer un document get http://HOST:PORT/mediatheque/film/1 Supprimer un document delete http://HOST:PORT/mediatheque/film/1 Créer un index post http://HOST:PORT/mediatheque/musique Rechercher get http://HOST:PORT/mediatheque/film/_search?q=django get http://HOST:PORT/_search?q=django
  • 17. Un langage de requêtes Query dsl match, field, query_string, bool, term, Fuzzy, match_all,more like this, geo, Range, wildcard, span, ...
  • 18. De nombreuses Facettes terms, histogram, date histogram, range, Stats, geo distance, filter, query ...
  • 19. facette « terms » curl -XGET 'localhost:9200/_search' -d ' { "query": { "match": { "titre": "django hard" } }, "facets": { "facet_genres": { "terms": { "field": "genre" } } } }'
  • 20. facette « terms » {... "hits":{ ... }, "facets":{ "facet_genres":{ "_type":"terms", "missing":0, "total":2, "other":0, "terms":[ {"term":"western","count":1}, {"term":"action","count":1} ] } } }
  • 21. facette « terms » {... "hits":{ ... }, "facets":{ "facet_genres":{ "_type":"terms", "missing":0, "total":2, "other":0, "terms":[ {"term":"western","count":1}, {"term":"action","count":1} ] } } }
  • 22. facette «histogramme» curl -XGET 'localhost:9200/media/film_search' -d ' { "query": { "match_all": {} }, "facets": { "facet_entrees": { "histogram": { "field": "nb_entrees", "interval": "1000000" } } } }'
  • 23. facette «histogramme» { "hits": { … }, "facets": { "facet_entrees": { "_type": "histogram", "entries": [ { "key": 1000000, "count": 1 }, { "key": 2000000, "count": 1 }, { "key": 3000000, "count": 1 } ] } } }
  • 24. facette «histogramme» { "hits": { … }, "facets": { "facet_entrees": { "_type": "histogram", "entries": [ { "key": 1000000, "count": 1 }, { "key": 2000000, "count": 1 }, { "key": 3000000, "count": 1 } ] } } }
  • 25. Elasticsearch est distribué Plusieurs nœuds communiquent en uni/multicast Node master, data, http ...
  • 26. Ils ont aussi pensé à la supervision
  • 28. Mais aussi tout plein d'autres clients Php, perl, scala, python, shell, ruby,.Net, Grails, play !, flume, clojure, Puppet, chef,...
  • 29. Un gros paquet de plugins Plugin d'analyse, rivers, transport, Site, misc, ...
  • 30. Extraction de texte avec Apache tika
  • 31. L'indexation facilitée avec les rivers Jdbc, Mongodb, couchdb, rabbitmq, activemq, Ldap, rss, twitter, wikipedia, ...
  • 32. Jdbc river plugin curl -XPUT 'localhost:9200/_river/my_jdbc_river/_meta' -d '{ "type" : "jdbc", "jdbc" : { "driver" : "com.mysql.jdbc.Driver", "url" : "jdbc:mysql://localhost:3306/test", "user" : "", "password" : "", "sql" : "select * from orders" } }'
  • 34. API percolate curl -XPUT localhost:9200/_percolator/media/film_box_office -d '{ "query": { "constant_score": { "filter": { "range": { "nb_entrees": { "from": "5000000", "include_lower": true } } } } } }'
  • 35. API percolate curl -XPOST 'localhost:9200/media/film/?percolate=*' -d '{ "titre":"Hollywoo", "genre":"drame", "nb_entrees": 6000000 }' { "ok":true, "_index":"media", "_type":"film", "_id":"70fc7FMWS8Sdxo733_5sWg", "_version":1, "matches":["film_box_office"] }
  • 36. Et aussi Parent/child Warmers Slowlog Script Backup ...