SlideShare une entreprise Scribd logo
1  sur  44
David Pilato
@dadoonet
elasticsearch
in 15 minutes
mercredi 3 juillet 13
Elasticsearch.com
• Créée en 2012 par les auteurs
d’Elasticsearch
• Formation (publique et intra)
• Consulting (support dév)
• Abonnement annuel support pour
la production avec 3 niveaux de
SLA
mercredi 3 juillet 13
Plug & Play
mercredi 3 juillet 13
Installation
$ wget https://download.elasticsearch.org/...
$ tar -xf elasticsearch-0.90.2.tar.gz
$ ./elasticsearch-0.90.2/bin/elasticsearch -f
... [INFO ][node][Ghost Maker] {0.90.2}[5645]: initializing ...
mercredi 3 juillet 13
Index a document...
$ curl -XPUT localhost:9200/products/product/1 -d '{
"title" : "Welcome!"
}'
mercredi 3 juillet 13
Update a document...
$ curl -XPUT localhost:9200/products/product/1 -d '{
"title" : "Welcome to the Elasticsearch meetup!"
}'
mercredi 3 juillet 13
{
"id" : "abc123",
"title" : "A JSON Document",
"body" : "A JSON document is a ...",
"published_on" : "2013/06/27 10:00:00",
"featured" : true,
"tags" : ["search", "json"],
"author" : {
"first_name" : "Clara",
"last_name" : "Rice",
"email" : "clara@rice.org"
}
}
Documents as JSON
Data structure with basic types, arrays and deep hierarchies
mercredi 3 juillet 13
Search for documents....
$ curl localhost:9200/products/_search?q=welcome
mercredi 3 juillet 13
Add a node...
$ ./elasticsearch-0.90.2/bin/elasticsearch -f -D es.node.name=Node2
...[cluster.service] [Node2] detected_master [Node1] ...
mercredi 3 juillet 13
Add a node...
$ ./elasticsearch-0.90.2/bin/elasticsearch -f -D es.node.name=Node2
...[cluster.service] [Node2] detected_master [Node1] ...
mercredi 3 juillet 13
Add another node...
$ ./elasticsearch-0.90.2/bin/elasticsearch -f -D es.node.name=Node3
...[cluster.service] [Node3] detected_master [Node1] ...
mercredi 3 juillet 13
Add another node...
$ ./elasticsearch-0.90.2/bin/elasticsearch -f -D es.node.name=Node3
...[cluster.service] [Node3] detected_master [Node1] ...
mercredi 3 juillet 13
Add another node...
$ ./elasticsearch-0.90.2/bin/elasticsearch -f -D es.node.name=Node3
...[cluster.service] [Node3] detected_master [Node1] ...
"index.routing.allocation.exclude.name" : "Node1"
"cluster.routing.allocation.exclude.name" : "Node3"
mercredi 3 juillet 13
mercredi 3 juillet 13
Until you know what to tweak...
mercredi 3 juillet 13
Search & Find
mercredi 3 juillet 13
Terms
apple
apple iphone
Phrases "apple iphone"
Proximity "apple safari"~5
Fuzzy apple~0.8
Wildcards
app*
*pp*
Boosting apple^10 safari
Range
[2011/05/01 TO 2011/05/31]
[java TO json]
Boolean
apple AND NOT iphone
+apple -iphone
(apple OR iphone) AND NOT review
Fields
title:iphone^15 OR body:iphone
published_on:[2011/05/01 TO "2011/05/27 10:00:00"]
http://lucene.apache.org/java/3_1_0/queryparsersyntax.html
$ curl -XGET "http://localhost:9200/_search?q=<YOUR QUERY>"
mercredi 3 juillet 13
JSON-based Query DSL
curl -XGET localhost:9200/articles/_search -d '{
"query" : {
"filtered" : {
"query" : {
"bool" : {
"must" : {
"match" : {
"author.first_name" : {
"query" : "claire",
"fuzziness" : 0.1
}
}
},
"must" : {
"multi_match" : {
"query" : "elasticsearch",
"fields" : ["title^10", "body"]
}
}
}
},
"filter": {
"and" : [
{ "terms" : { "tags" : ["search"] } },
{ "range" : { "published_on": {"from": "2013"} } },
{ "term" : { "featured" : true } }
]
}
}
}
}'
mercredi 3 juillet 13
JSON-based Query DSL
curl -XGET localhost:9200/articles/_search -d '{
"query" : {
"filtered" : {
"query" : {
"bool" : {
"must" : {
"match" : {
"author.first_name" : {
"query" : "claire",
"fuzziness" : 0.1
}
}
},
"must" : {
"multi_match" : {
"query" : "elasticsearch",
"fields" : ["title^10", "body"]
}
}
}
},
"filter": {
"and" : [
{ "terms" : { "tags" : ["search"] } },
{ "range" : { "published_on": {"from": "2013"} } },
{ "term" : { "featured" : true } }
]
}
}
}
}'
mercredi 3 juillet 13
curl -XGET localhost:9200/articles/_search -d '{
"query" : {
"filtered" : {
"query" : {
"bool" : {
"must" : {
"match" : {
"author.first_name" : {
"query" : "claire",
"fuzziness" : 0.1
}
}
},
"must" : {
"multi_match" : {
"query" : "elasticsearch",
"fields" : ["title^10", "body"]
}
}
}
},
"filter": {
"and" : [
{ "terms" : { "tags" : ["search"] } },
{ "range" : { "published_on": {"from": "2013"} } },
{ "term" : { "featured" : true } }
]
}
}
}
}'
JSON-based Query DSL
mercredi 3 juillet 13
JSON-based Query DSL
curl -XGET localhost:9200/articles/_search -d '{
"query" : {
"filtered" : {
"query" : {
"bool" : {
"must" : {
"match" : {
"author.first_name" : {
"query" : "claire",
"fuzziness" : 0.1
}
}
},
"must" : {
"multi_match" : {
"query" : "elasticsearch",
"fields" : ["title^10", "body"]
}
}
}
},
"filter": {
"and" : [
{ "terms" : { "tags" : ["search"] } },
{ "range" : { "published_on": {"from": "2013"} } },
{ "term" : { "featured" : true } }
]
}
}
}
}'
mercredi 3 juillet 13
JSON-based Query DSL
curl -XGET localhost:9200/articles/_search -d '{
"query" : {
"filtered" : {
"query" : {
"bool" : {
"must" : {
"match" : {
"author.first_name" : {
"query" : "claire",
"fuzziness" : 0.1
}
}
},
"must" : {
"multi_match" : {
"query" : "elasticsearch",
"fields" : ["title^10", "body"]
}
}
}
},
"filter": {
"and" : [
{ "terms" : { "tags" : ["search"] } },
{ "range" : { "published_on": {"from": "2013"} } },
{ "term" : { "featured" : true } }
]
}
}
}
}'
mercredi 3 juillet 13
“Find all articles with ‘search’ in their title or body, give
matches in titles higher score”
Full-text Search
“Find all articles from year 2013 tagged ‘search’”
Structured Search
See custom_score and custom_filters_score queries
Custom Scoring
“Find all articles with ‘search’ in their title or body, give
matches in titles higher score and filter articles from year 2013
tagged ‘search’ “
Combined Search
mercredi 3 juillet 13
What is really a search engine?
mercredi 3 juillet 13
What is really a search engine?
mercredi 3 juillet 13
Fetch document field ➝ Pick configured analyzer ➝ Parse
text into tokens ➝ Apply token filters ➝ Store into index
What is really a search engine?
mercredi 3 juillet 13
The _analyze API
_analyze?text=...&tokenizer=X&filters=A,B,C
mercredi 3 juillet 13
curl 'localhost:9200/_analyze?pretty&tokenizer=keyword&filters=lowercase' 
-d 'This is a Test'
The _analyze API
_analyze?text=...&tokenizer=X&filters=A,B,C
mercredi 3 juillet 13
curl 'localhost:9200/_analyze?pretty&tokenizer=keyword&filters=lowercase' 
-d 'This is a Test'
The _analyze API
{
"tokens" : [ {
"token" : "this is a test",
"start_offset" : 0, "end_offset" : 14,
"type" : "word", "position" : 1
} ]
}
_analyze?text=...&tokenizer=X&filters=A,B,C
mercredi 3 juillet 13
curl 'localhost:9200/_analyze?pretty&tokenizer=keyword&filters=lowercase' 
-d 'This is a Test'
The _analyze API
{
"tokens" : [ {
"token" : "this is a test",
"start_offset" : 0, "end_offset" : 14,
"type" : "word", "position" : 1
} ]
}
_analyze?text=...&tokenizer=X&filters=A,B,C
curl 'localhost:9200/_analyze?pretty&analyzer=standard' -d 'This is a Test'
mercredi 3 juillet 13
curl 'localhost:9200/_analyze?pretty&tokenizer=keyword&filters=lowercase' 
-d 'This is a Test'
The _analyze API
{
"tokens" : [ {
"token" : "this is a test",
"start_offset" : 0, "end_offset" : 14,
"type" : "word", "position" : 1
} ]
}
_analyze?text=...&tokenizer=X&filters=A,B,C
curl 'localhost:9200/_analyze?pretty&analyzer=standard' -d 'This is a Test'
{
"tokens" : [ {
"token" : "test",
"start_offset" : 10, "end_offset" : 14,
"type" : "<ALPHANUM>", "position" : 4
} ]
}
mercredi 3 juillet 13
Mapping
curl -XPUT localhost:9200/articles/_mapping -d '{
"article" : {
"properties" : {
"title" : {
"type" : "string",
"analyzer" : "french"
}
}
}
}'
Configuring document properties for the search engine
mercredi 3 juillet 13
Slice & Dice
mercredi 3 juillet 13
Query
Facets
mercredi 3 juillet 13
Location
Product
Tim
e
OLAP Cube
Dimensions, measures, aggregations
mercredi 3 juillet 13
Slice Dice Drill Down / Roll Up
Show me sales numbers for all products across all locations in year 2013
Show me product A sales numbers across all locations over all years
Show me products sales numbers in location X over all years
mercredi 3 juillet 13
curl -XPOST 'localhost:9200/articles/_search?search_type=count&pretty' -d '{
"facets": {
"tag-cloug": {
"terms" : {
"field" : "tags"
}
}
}
}'
“Tag Cloud” With the terms Facet
"facets" : {
"tag-cloug" : {
"terms" : [ {
"term" : "ruby",
"count" : 3
}, {
"term" : "java",
"count" : 2
},
...
} ]
}
}
Simplest “map/reduce” aggregation: document count per tag
mercredi 3 juillet 13
curl -XGET 'localhost:9200/scores/_search/?search_type=count&pretty' -d '{
"facets": {
"scores-per-subject" : {
"terms_stats" : {
"key_field" : "subject",
"value_field" : "score"
}
}
}
}'
Statistics on Student Scores With the terms_stats Facet
"facets" : {
"scores-per-subject" : {
"_type" : "terms_stats",
"missing" : 0,
"terms" : [ {
"term" : "math",
"count" : 4,
"total_count" : 4,
"min" : 25.0,
"max" : 92.0,
"total" : 267.0,
"mean" : 66.75
}, ... ]
}
}
Aggregating statistics per subject
mercredi 3 juillet 13
curl -X GET 'localhost:9200/demo-scores/_search/?search_type=count&pretty'
'{
"query" : {
"match" : {
"student" : "john"
}
},
"facets": {
"scores-per-subject" : {
"terms_stats" : {
"key_field" : "subject",
"value_field" : "score"
}
}
}
}'
Statistics on Student Scores With the terms_stats Facet
"facets" : {
"scores-per-subject" : {
"_type" : "terms_stats",
"missing" : 0,
"terms" : [ {
"term" : "math",
"count" : 1,
"total_count" : 1,
"min" : 85.0,
"max" : 85.0,
"total" : 85.0,
"mean" : 85.0
}, ... ]
}
}
Realtime filtering with queries and filters
mercredi 3 juillet 13
Facets
Terms
Terms Stats
Statistical
Range
Histogram
Date Histogram
Filter
Query
Geo Distance
mercredi 3 juillet 13
Above
& 
Beyond
mercredi 3 juillet 13
Above & Beyond
Bulk operations (For indexing and search operations)
Percolator (“reversed search” — alerts, classification, …)
Suggesters (“Did you mean …?”)
Index aliases (Grouping, filtering or “renaming” of indices)
Index templates (Automatic index configuration)
Monitoring API (Amount of memory used, number of operations, …)
…
mercredi 3 juillet 13
Above & Beyond
Bulk operations (For indexing and search operations)
Percolator (“reversed search” — alerts, classification, …)
Suggesters (“Did you mean …?”)
Index aliases (Grouping, filtering or “renaming” of indices)
Index templates (Automatic index configuration)
Monitoring API (Amount of memory used, number of operations, …)
…
GUI?
Give Kibana a try
http://three.kibana.org/
mercredi 3 juillet 13
thanks!
David Pilato
@dadoonet
mercredi 3 juillet 13

Contenu connexe

Tendances

Elastic search apache_solr
Elastic search apache_solrElastic search apache_solr
Elastic search apache_solr
macrochen
 

Tendances (20)

Elasticsearch Introduction at BigData meetup
Elasticsearch Introduction at BigData meetupElasticsearch Introduction at BigData meetup
Elasticsearch Introduction at BigData meetup
 
Elasticsearch: You know, for search! and more!
Elasticsearch: You know, for search! and more!Elasticsearch: You know, for search! and more!
Elasticsearch: You know, for search! and more!
 
ElasticSearch in action
ElasticSearch in actionElasticSearch in action
ElasticSearch in action
 
Solr vs. Elasticsearch - Case by Case
Solr vs. Elasticsearch - Case by CaseSolr vs. Elasticsearch - Case by Case
Solr vs. Elasticsearch - Case by Case
 
Cool bonsai cool - an introduction to ElasticSearch
Cool bonsai cool - an introduction to ElasticSearchCool bonsai cool - an introduction to ElasticSearch
Cool bonsai cool - an introduction to ElasticSearch
 
Elasticsearch
ElasticsearchElasticsearch
Elasticsearch
 
Introduction to Elasticsearch with basics of Lucene
Introduction to Elasticsearch with basics of LuceneIntroduction to Elasticsearch with basics of Lucene
Introduction to Elasticsearch with basics of Lucene
 
Query DSL In Elasticsearch
Query DSL In ElasticsearchQuery DSL In Elasticsearch
Query DSL In Elasticsearch
 
ElasticSearch - DevNexus Atlanta - 2014
ElasticSearch - DevNexus Atlanta - 2014ElasticSearch - DevNexus Atlanta - 2014
ElasticSearch - DevNexus Atlanta - 2014
 
Intro to Elasticsearch
Intro to ElasticsearchIntro to Elasticsearch
Intro to Elasticsearch
 
Managing Your Content with Elasticsearch
Managing Your Content with ElasticsearchManaging Your Content with Elasticsearch
Managing Your Content with Elasticsearch
 
Elasticsearch for Data Analytics
Elasticsearch for Data AnalyticsElasticsearch for Data Analytics
Elasticsearch for Data Analytics
 
Elastic search apache_solr
Elastic search apache_solrElastic search apache_solr
Elastic search apache_solr
 
Elastic search overview
Elastic search overviewElastic search overview
Elastic search overview
 
Elasticsearch Introduction
Elasticsearch IntroductionElasticsearch Introduction
Elasticsearch Introduction
 
ElasticSearch for .NET Developers
ElasticSearch for .NET DevelopersElasticSearch for .NET Developers
ElasticSearch for .NET Developers
 
Philly PHP: April '17 Elastic Search Introduction by Aditya Bhamidpati
Philly PHP: April '17 Elastic Search Introduction by Aditya BhamidpatiPhilly PHP: April '17 Elastic Search Introduction by Aditya Bhamidpati
Philly PHP: April '17 Elastic Search Introduction by Aditya Bhamidpati
 
What I learnt: Elastic search & Kibana : introduction, installtion & configur...
What I learnt: Elastic search & Kibana : introduction, installtion & configur...What I learnt: Elastic search & Kibana : introduction, installtion & configur...
What I learnt: Elastic search & Kibana : introduction, installtion & configur...
 
Elastic Search
Elastic SearchElastic Search
Elastic Search
 
Intro to elasticsearch
Intro to elasticsearchIntro to elasticsearch
Intro to elasticsearch
 

Similaire à Elasticsearch in 15 minutes

Real-time search in Drupal with Elasticsearch @Moldcamp
Real-time search in Drupal with Elasticsearch @MoldcampReal-time search in Drupal with Elasticsearch @Moldcamp
Real-time search in Drupal with Elasticsearch @Moldcamp
Alexei Gorobets
 

Similaire à Elasticsearch in 15 minutes (20)

Elasticsearch in 15 Minutes
Elasticsearch in 15 MinutesElasticsearch in 15 Minutes
Elasticsearch in 15 Minutes
 
elasticsearch basics workshop
elasticsearch basics workshopelasticsearch basics workshop
elasticsearch basics workshop
 
Elasticsearch – mye mer enn søk! [JavaZone 2013]
Elasticsearch – mye mer enn søk! [JavaZone 2013]Elasticsearch – mye mer enn søk! [JavaZone 2013]
Elasticsearch – mye mer enn søk! [JavaZone 2013]
 
Full-Text Search Explained - Philipp Krenn - Codemotion Rome 2017
Full-Text Search Explained - Philipp Krenn - Codemotion Rome 2017Full-Text Search Explained - Philipp Krenn - Codemotion Rome 2017
Full-Text Search Explained - Philipp Krenn - Codemotion Rome 2017
 
Real-time search in Drupal with Elasticsearch @Moldcamp
Real-time search in Drupal with Elasticsearch @MoldcampReal-time search in Drupal with Elasticsearch @Moldcamp
Real-time search in Drupal with Elasticsearch @Moldcamp
 
Elasticsearch & "PeopleSearch"
Elasticsearch & "PeopleSearch"Elasticsearch & "PeopleSearch"
Elasticsearch & "PeopleSearch"
 
JSON and the APInauts
JSON and the APInautsJSON and the APInauts
JSON and the APInauts
 
Finding the right stuff, an intro to Elasticsearch (at Rug::B)
Finding the right stuff, an intro to Elasticsearch (at Rug::B) Finding the right stuff, an intro to Elasticsearch (at Rug::B)
Finding the right stuff, an intro to Elasticsearch (at Rug::B)
 
Elastic search and Symfony3 - A practical approach
Elastic search and Symfony3 - A practical approachElastic search and Symfony3 - A practical approach
Elastic search and Symfony3 - A practical approach
 
OData: Universal Data Solvent or Clunky Enterprise Goo? (GlueCon 2015)
OData: Universal Data Solvent or Clunky Enterprise Goo? (GlueCon 2015)OData: Universal Data Solvent or Clunky Enterprise Goo? (GlueCon 2015)
OData: Universal Data Solvent or Clunky Enterprise Goo? (GlueCon 2015)
 
Making your elastic cluster perform - Jettro Coenradie - Codemotion Amsterdam...
Making your elastic cluster perform - Jettro Coenradie - Codemotion Amsterdam...Making your elastic cluster perform - Jettro Coenradie - Codemotion Amsterdam...
Making your elastic cluster perform - Jettro Coenradie - Codemotion Amsterdam...
 
Peggy elasticsearch應用
Peggy elasticsearch應用Peggy elasticsearch應用
Peggy elasticsearch應用
 
Elasticsearch intro output
Elasticsearch intro outputElasticsearch intro output
Elasticsearch intro output
 
REST with Eve and Python
REST with Eve and PythonREST with Eve and Python
REST with Eve and Python
 
Overview of GraphQL & Clients
Overview of GraphQL & ClientsOverview of GraphQL & Clients
Overview of GraphQL & Clients
 
Stop the noise! - Introduction to the JSON:API specification in Drupal
Stop the noise! - Introduction to the JSON:API specification in DrupalStop the noise! - Introduction to the JSON:API specification in Drupal
Stop the noise! - Introduction to the JSON:API specification in Drupal
 
GraphQL & Relay - 串起前後端世界的橋樑
GraphQL & Relay - 串起前後端世界的橋樑GraphQL & Relay - 串起前後端世界的橋樑
GraphQL & Relay - 串起前後端世界的橋樑
 
Elasticsearch sur Azure : Make sense of your (BIG) data !
Elasticsearch sur Azure : Make sense of your (BIG) data !Elasticsearch sur Azure : Make sense of your (BIG) data !
Elasticsearch sur Azure : Make sense of your (BIG) data !
 
Finding the right stuff, an intro to Elasticsearch with Ruby/Rails
Finding the right stuff, an intro to Elasticsearch with Ruby/RailsFinding the right stuff, an intro to Elasticsearch with Ruby/Rails
Finding the right stuff, an intro to Elasticsearch with Ruby/Rails
 
Introduction to Elasticsearch
Introduction to ElasticsearchIntroduction to Elasticsearch
Introduction to Elasticsearch
 

Plus de David Pilato

Plus de David Pilato (20)

2018-10-02 - Un moteur de recherche NoSQL pour chercher^H^H^H^H^H^H^H^H trouv...
2018-10-02 - Un moteur de recherche NoSQL pour chercher^H^H^H^H^H^H^H^H trouv...2018-10-02 - Un moteur de recherche NoSQL pour chercher^H^H^H^H^H^H^H^H trouv...
2018-10-02 - Un moteur de recherche NoSQL pour chercher^H^H^H^H^H^H^H^H trouv...
 
Managing your black friday logs Voxxed Luxembourg
Managing your black friday logs Voxxed LuxembourgManaging your black friday logs Voxxed Luxembourg
Managing your black friday logs Voxxed Luxembourg
 
Un moteur de recherche NoSQL pour chercher^H^H^H^H^H^H^H^H trouver...
Un moteur de recherche NoSQL pour chercher^H^H^H^H^H^H^H^H trouver...Un moteur de recherche NoSQL pour chercher^H^H^H^H^H^H^H^H trouver...
Un moteur de recherche NoSQL pour chercher^H^H^H^H^H^H^H^H trouver...
 
Managing your Black Friday Logs NDC Oslo
Managing your  Black Friday Logs NDC OsloManaging your  Black Friday Logs NDC Oslo
Managing your Black Friday Logs NDC Oslo
 
Managing your black friday logs - Code Europe
Managing your black friday logs - Code EuropeManaging your black friday logs - Code Europe
Managing your black friday logs - Code Europe
 
Managing your black Friday logs - CloudConf.IT
Managing your black Friday logs - CloudConf.ITManaging your black Friday logs - CloudConf.IT
Managing your black Friday logs - CloudConf.IT
 
Elastify you application: from SQL to NoSQL in less than one hour!
Elastify you application: from SQL to NoSQL in less than one hour!Elastify you application: from SQL to NoSQL in less than one hour!
Elastify you application: from SQL to NoSQL in less than one hour!
 
Elasticsearch - Esme sudria
Elasticsearch - Esme sudriaElasticsearch - Esme sudria
Elasticsearch - Esme sudria
 
Lausanne JUG - Elasticsearch
Lausanne JUG - ElasticsearchLausanne JUG - Elasticsearch
Lausanne JUG - Elasticsearch
 
Normandy JUG - Elasticsearch
Normandy JUG - ElasticsearchNormandy JUG - Elasticsearch
Normandy JUG - Elasticsearch
 
Paris data geek - Elasticsearch
Paris data geek - ElasticsearchParis data geek - Elasticsearch
Paris data geek - Elasticsearch
 
Nantes JUG - Elasticsearch
Nantes JUG - ElasticsearchNantes JUG - Elasticsearch
Nantes JUG - Elasticsearch
 
Finist JUG - Elasticsearch
Finist JUG - ElasticsearchFinist JUG - Elasticsearch
Finist JUG - Elasticsearch
 
Poitou charentes JUG - Elasticsearch
Poitou charentes JUG - ElasticsearchPoitou charentes JUG - Elasticsearch
Poitou charentes JUG - Elasticsearch
 
Elasticsearch - Montpellier JUG
Elasticsearch - Montpellier JUGElasticsearch - Montpellier JUG
Elasticsearch - Montpellier JUG
 
Lyon JUG - Elasticsearch
Lyon JUG - ElasticsearchLyon JUG - Elasticsearch
Lyon JUG - Elasticsearch
 
Elasticsearch - OSDC France 2012
Elasticsearch - OSDC France 2012Elasticsearch - OSDC France 2012
Elasticsearch - OSDC France 2012
 
Hands on lab Elasticsearch
Hands on lab ElasticsearchHands on lab Elasticsearch
Hands on lab Elasticsearch
 
Elasticsearch - Devoxx France 2012 - English version
Elasticsearch - Devoxx France 2012 - English versionElasticsearch - Devoxx France 2012 - English version
Elasticsearch - Devoxx France 2012 - English version
 
Elasticsearch - Devoxx France 2012
Elasticsearch - Devoxx France 2012Elasticsearch - Devoxx France 2012
Elasticsearch - Devoxx France 2012
 

Dernier

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Dernier (20)

Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 

Elasticsearch in 15 minutes

  • 1. David Pilato @dadoonet elasticsearch in 15 minutes mercredi 3 juillet 13
  • 2. Elasticsearch.com • Créée en 2012 par les auteurs d’Elasticsearch • Formation (publique et intra) • Consulting (support dév) • Abonnement annuel support pour la production avec 3 niveaux de SLA mercredi 3 juillet 13
  • 4. Installation $ wget https://download.elasticsearch.org/... $ tar -xf elasticsearch-0.90.2.tar.gz $ ./elasticsearch-0.90.2/bin/elasticsearch -f ... [INFO ][node][Ghost Maker] {0.90.2}[5645]: initializing ... mercredi 3 juillet 13
  • 5. Index a document... $ curl -XPUT localhost:9200/products/product/1 -d '{ "title" : "Welcome!" }' mercredi 3 juillet 13
  • 6. Update a document... $ curl -XPUT localhost:9200/products/product/1 -d '{ "title" : "Welcome to the Elasticsearch meetup!" }' mercredi 3 juillet 13
  • 7. { "id" : "abc123", "title" : "A JSON Document", "body" : "A JSON document is a ...", "published_on" : "2013/06/27 10:00:00", "featured" : true, "tags" : ["search", "json"], "author" : { "first_name" : "Clara", "last_name" : "Rice", "email" : "clara@rice.org" } } Documents as JSON Data structure with basic types, arrays and deep hierarchies mercredi 3 juillet 13
  • 8. Search for documents.... $ curl localhost:9200/products/_search?q=welcome mercredi 3 juillet 13
  • 9. Add a node... $ ./elasticsearch-0.90.2/bin/elasticsearch -f -D es.node.name=Node2 ...[cluster.service] [Node2] detected_master [Node1] ... mercredi 3 juillet 13
  • 10. Add a node... $ ./elasticsearch-0.90.2/bin/elasticsearch -f -D es.node.name=Node2 ...[cluster.service] [Node2] detected_master [Node1] ... mercredi 3 juillet 13
  • 11. Add another node... $ ./elasticsearch-0.90.2/bin/elasticsearch -f -D es.node.name=Node3 ...[cluster.service] [Node3] detected_master [Node1] ... mercredi 3 juillet 13
  • 12. Add another node... $ ./elasticsearch-0.90.2/bin/elasticsearch -f -D es.node.name=Node3 ...[cluster.service] [Node3] detected_master [Node1] ... mercredi 3 juillet 13
  • 13. Add another node... $ ./elasticsearch-0.90.2/bin/elasticsearch -f -D es.node.name=Node3 ...[cluster.service] [Node3] detected_master [Node1] ... "index.routing.allocation.exclude.name" : "Node1" "cluster.routing.allocation.exclude.name" : "Node3" mercredi 3 juillet 13
  • 15. Until you know what to tweak... mercredi 3 juillet 13
  • 17. Terms apple apple iphone Phrases "apple iphone" Proximity "apple safari"~5 Fuzzy apple~0.8 Wildcards app* *pp* Boosting apple^10 safari Range [2011/05/01 TO 2011/05/31] [java TO json] Boolean apple AND NOT iphone +apple -iphone (apple OR iphone) AND NOT review Fields title:iphone^15 OR body:iphone published_on:[2011/05/01 TO "2011/05/27 10:00:00"] http://lucene.apache.org/java/3_1_0/queryparsersyntax.html $ curl -XGET "http://localhost:9200/_search?q=<YOUR QUERY>" mercredi 3 juillet 13
  • 18. JSON-based Query DSL curl -XGET localhost:9200/articles/_search -d '{ "query" : { "filtered" : { "query" : { "bool" : { "must" : { "match" : { "author.first_name" : { "query" : "claire", "fuzziness" : 0.1 } } }, "must" : { "multi_match" : { "query" : "elasticsearch", "fields" : ["title^10", "body"] } } } }, "filter": { "and" : [ { "terms" : { "tags" : ["search"] } }, { "range" : { "published_on": {"from": "2013"} } }, { "term" : { "featured" : true } } ] } } } }' mercredi 3 juillet 13
  • 19. JSON-based Query DSL curl -XGET localhost:9200/articles/_search -d '{ "query" : { "filtered" : { "query" : { "bool" : { "must" : { "match" : { "author.first_name" : { "query" : "claire", "fuzziness" : 0.1 } } }, "must" : { "multi_match" : { "query" : "elasticsearch", "fields" : ["title^10", "body"] } } } }, "filter": { "and" : [ { "terms" : { "tags" : ["search"] } }, { "range" : { "published_on": {"from": "2013"} } }, { "term" : { "featured" : true } } ] } } } }' mercredi 3 juillet 13
  • 20. curl -XGET localhost:9200/articles/_search -d '{ "query" : { "filtered" : { "query" : { "bool" : { "must" : { "match" : { "author.first_name" : { "query" : "claire", "fuzziness" : 0.1 } } }, "must" : { "multi_match" : { "query" : "elasticsearch", "fields" : ["title^10", "body"] } } } }, "filter": { "and" : [ { "terms" : { "tags" : ["search"] } }, { "range" : { "published_on": {"from": "2013"} } }, { "term" : { "featured" : true } } ] } } } }' JSON-based Query DSL mercredi 3 juillet 13
  • 21. JSON-based Query DSL curl -XGET localhost:9200/articles/_search -d '{ "query" : { "filtered" : { "query" : { "bool" : { "must" : { "match" : { "author.first_name" : { "query" : "claire", "fuzziness" : 0.1 } } }, "must" : { "multi_match" : { "query" : "elasticsearch", "fields" : ["title^10", "body"] } } } }, "filter": { "and" : [ { "terms" : { "tags" : ["search"] } }, { "range" : { "published_on": {"from": "2013"} } }, { "term" : { "featured" : true } } ] } } } }' mercredi 3 juillet 13
  • 22. JSON-based Query DSL curl -XGET localhost:9200/articles/_search -d '{ "query" : { "filtered" : { "query" : { "bool" : { "must" : { "match" : { "author.first_name" : { "query" : "claire", "fuzziness" : 0.1 } } }, "must" : { "multi_match" : { "query" : "elasticsearch", "fields" : ["title^10", "body"] } } } }, "filter": { "and" : [ { "terms" : { "tags" : ["search"] } }, { "range" : { "published_on": {"from": "2013"} } }, { "term" : { "featured" : true } } ] } } } }' mercredi 3 juillet 13
  • 23. “Find all articles with ‘search’ in their title or body, give matches in titles higher score” Full-text Search “Find all articles from year 2013 tagged ‘search’” Structured Search See custom_score and custom_filters_score queries Custom Scoring “Find all articles with ‘search’ in their title or body, give matches in titles higher score and filter articles from year 2013 tagged ‘search’ “ Combined Search mercredi 3 juillet 13
  • 24. What is really a search engine? mercredi 3 juillet 13
  • 25. What is really a search engine? mercredi 3 juillet 13
  • 26. Fetch document field ➝ Pick configured analyzer ➝ Parse text into tokens ➝ Apply token filters ➝ Store into index What is really a search engine? mercredi 3 juillet 13
  • 28. curl 'localhost:9200/_analyze?pretty&tokenizer=keyword&filters=lowercase' -d 'This is a Test' The _analyze API _analyze?text=...&tokenizer=X&filters=A,B,C mercredi 3 juillet 13
  • 29. curl 'localhost:9200/_analyze?pretty&tokenizer=keyword&filters=lowercase' -d 'This is a Test' The _analyze API { "tokens" : [ { "token" : "this is a test", "start_offset" : 0, "end_offset" : 14, "type" : "word", "position" : 1 } ] } _analyze?text=...&tokenizer=X&filters=A,B,C mercredi 3 juillet 13
  • 30. curl 'localhost:9200/_analyze?pretty&tokenizer=keyword&filters=lowercase' -d 'This is a Test' The _analyze API { "tokens" : [ { "token" : "this is a test", "start_offset" : 0, "end_offset" : 14, "type" : "word", "position" : 1 } ] } _analyze?text=...&tokenizer=X&filters=A,B,C curl 'localhost:9200/_analyze?pretty&analyzer=standard' -d 'This is a Test' mercredi 3 juillet 13
  • 31. curl 'localhost:9200/_analyze?pretty&tokenizer=keyword&filters=lowercase' -d 'This is a Test' The _analyze API { "tokens" : [ { "token" : "this is a test", "start_offset" : 0, "end_offset" : 14, "type" : "word", "position" : 1 } ] } _analyze?text=...&tokenizer=X&filters=A,B,C curl 'localhost:9200/_analyze?pretty&analyzer=standard' -d 'This is a Test' { "tokens" : [ { "token" : "test", "start_offset" : 10, "end_offset" : 14, "type" : "<ALPHANUM>", "position" : 4 } ] } mercredi 3 juillet 13
  • 32. Mapping curl -XPUT localhost:9200/articles/_mapping -d '{ "article" : { "properties" : { "title" : { "type" : "string", "analyzer" : "french" } } } }' Configuring document properties for the search engine mercredi 3 juillet 13
  • 35. Location Product Tim e OLAP Cube Dimensions, measures, aggregations mercredi 3 juillet 13
  • 36. Slice Dice Drill Down / Roll Up Show me sales numbers for all products across all locations in year 2013 Show me product A sales numbers across all locations over all years Show me products sales numbers in location X over all years mercredi 3 juillet 13
  • 37. curl -XPOST 'localhost:9200/articles/_search?search_type=count&pretty' -d '{ "facets": { "tag-cloug": { "terms" : { "field" : "tags" } } } }' “Tag Cloud” With the terms Facet "facets" : { "tag-cloug" : { "terms" : [ { "term" : "ruby", "count" : 3 }, { "term" : "java", "count" : 2 }, ... } ] } } Simplest “map/reduce” aggregation: document count per tag mercredi 3 juillet 13
  • 38. curl -XGET 'localhost:9200/scores/_search/?search_type=count&pretty' -d '{ "facets": { "scores-per-subject" : { "terms_stats" : { "key_field" : "subject", "value_field" : "score" } } } }' Statistics on Student Scores With the terms_stats Facet "facets" : { "scores-per-subject" : { "_type" : "terms_stats", "missing" : 0, "terms" : [ { "term" : "math", "count" : 4, "total_count" : 4, "min" : 25.0, "max" : 92.0, "total" : 267.0, "mean" : 66.75 }, ... ] } } Aggregating statistics per subject mercredi 3 juillet 13
  • 39. curl -X GET 'localhost:9200/demo-scores/_search/?search_type=count&pretty' '{ "query" : { "match" : { "student" : "john" } }, "facets": { "scores-per-subject" : { "terms_stats" : { "key_field" : "subject", "value_field" : "score" } } } }' Statistics on Student Scores With the terms_stats Facet "facets" : { "scores-per-subject" : { "_type" : "terms_stats", "missing" : 0, "terms" : [ { "term" : "math", "count" : 1, "total_count" : 1, "min" : 85.0, "max" : 85.0, "total" : 85.0, "mean" : 85.0 }, ... ] } } Realtime filtering with queries and filters mercredi 3 juillet 13
  • 42. Above & Beyond Bulk operations (For indexing and search operations) Percolator (“reversed search” — alerts, classification, …) Suggesters (“Did you mean …?”) Index aliases (Grouping, filtering or “renaming” of indices) Index templates (Automatic index configuration) Monitoring API (Amount of memory used, number of operations, …) … mercredi 3 juillet 13
  • 43. Above & Beyond Bulk operations (For indexing and search operations) Percolator (“reversed search” — alerts, classification, …) Suggesters (“Did you mean …?”) Index aliases (Grouping, filtering or “renaming” of indices) Index templates (Automatic index configuration) Monitoring API (Amount of memory used, number of operations, …) … GUI? Give Kibana a try http://three.kibana.org/ mercredi 3 juillet 13