SlideShare uma empresa Scribd logo
1 de 57
Baixar para ler offline
Learning
ElasticSearch
—
Fifth Elephant 2013, Bangalore.
Anurag Patel Red Hat
http://xinh.org/5el
Also available at
ElasticWho?
ElasticSearch is a flexible and powerful open source, distributed
real-time search and analytics engine.
Features
Real time analytics
Distributed
High availability
Multi tenant architecture
Full text
Document oriented
Schema free
RESTful API
Per-operation persistence
Distributed
Start small and scale horizontally out of the box. For more capacity,
just add more nodes and let the cluster reorganize itself.
High Availability
ElasticSearch clusters detect and remove failed nodes, and
reorganize themselves.
Multi Tenancy
A cluster can host multiple indices which can be queried
independently, or as a group.
$ curl -XPUT http://localhost:9200/people
$ curl -XPUT http://localhost:9200/gems
$ curl -XPUT http://localhost:9200/gems/document/pry-0.5.9
$ curl -XGET http://localhost:9200/gems/document/pry-0.5.9
Document Oriented
Store complex real world entities in Elasticsearch as structured JSON
documents.
{
"_id": "pry-0.5.9",
"_index": "gems",
"_source": {
"authors": [
"John Mair (banisterfiend)"
],
"autorequire": null,
"bindir": "bin",
"cert_chain": [],
"date": "Sun Feb 20 11:00:00 UTC 2011",
"default_executable": null,
"description": "attach an irb-like session to any object at runtime",
"email": "jrmair@gmail.com"
}
}
RESTful API
Almost any operation can be performed using a simple RESTful
interface using JSON over HTTP.
curl -X GET
curl -X PUT
curl -X POST
curl -X DELETE
Apache Lucene
ElasticSearch is built on top of Apache Lucene. Lucene is a high
performance, full-featured Information Retrieval library, written in
Java.
ElasticSearch Terminology
Document
$ curl -XGET http://localhost:9200/gems/document/pry-0.5.9
In ElasticSearch, everything is stored as a Document. Document can
be addressed and retrieved by querying their attributes.
{
"_id": "pry-0.5.9",
"_index": "gems",
"_source": {
"authors": [
"John Mair (banisterfiend)"
],
"autorequire": null,
"bindir": "bin",
"cert_chain": [],
"date": "Sun Feb 20 11:00:00 UTC 2011",
"default_executable": null,
"description": "attach an irb-like session to any object at runtime",
"email": "jrmair@gmail.com",
"executables": [
"pry"
],
"extensions": [],
"extra_rdoc_files": [],
"files": [
"lib/pry/commands.rb",
"lib/pry/command_base.rb",
"lib/pry/completion.rb",
"lib/pry/core_extensions.rb",
"lib/pry/hooks.rb",
"lib/pry/print.rb",
"lib/pry/prompts.rb",
"lib/pry/pry_class.rb",
"lib/pry/pry_instance.rb",
"lib/pry/version.rb",
"lib/pry.rb",
"examples/example_basic.rb",
Document Types
Lets us specify document properties, so we can differentiate the
objects.
Shard
Each Shard is a separate native Lucene Index. Lets us overcome RAM
limitations, hard disk capacity.
Replica
An exact copy of primary Shard. Helps in setting up HA, increases
query throughput.
Index
ElasticSearch stores its data in logical Indices. Think of a table,
collection or a database.
An Index has atleast 1 primary Shard, and 0 or more Replicas.
Cluster
A collection of cooperating ElasticSearch nodes. Gives better
availability and performance via Index Sharding and Replicas.
ElasticSearch Workshop
Download and start
Download ElasticSearch from
http://www.elasticsearch.org/download
# service elasticsearch start
# /etc/init.d/elasticsearch start
# ./bin/elasticsearch -f
ElasticSearch Plugins
A site plugin to view contents of ElasticSearch cluster.
Restart ElasticSearch. Plugins are detected and loaded on service
startup.
# cd /usr/share/elasticsearch
# ./bin/plugin -install mobz/elasticsearch-head
# cd /opt/elasticsearch-0.90.2
# ./bin/plugin -install mobz/elasticsearch-head
elasticsearch-head
RESTful interface
$ curl -XGET 'http://localhost:9200/'
{
"ok" : true,
"status" : 200,
"name" : "Drake, Frank",
"version" : {
"number" : "0.90.2",
"snapshot_build" : false,
"lucene_version" : "4.3.1"
},
"tagline" : "You Know, for Search"
}
Create Index
$ curl -XPUT 'http://localhost:9200/gems'
{
"ok":true,
"acknowledged":true
}
Cluster status
$ curl -XGET 'localhost:9200/_status'
{"ok":true,"_shards":{"total":20,"successful":10,"failed":0},
"indices":{"gems":{"index":{"primary_size":"495b","primary_size_in_bytes":495,
"size":"495b","size_in_bytes":495},"translog":{"operations":0},
"docs":{"num_docs":0,"max_doc":0,"deleted_docs":0},"merges":
{"current":0,"current_docs":0,"current_size":"0b","current_size_in_bytes":0,
"total":0,"total_time":"0s","total_time_in_millis":0,"total_docs":0,
"total_size":"0b","total_size_in_bytes":0},
...
...
...
Pretty Output
$ curl -XGET 'localhost:9200/_status?pretty'
$ curl -XGET 'localhost:9200/_status' | python -mjson.tool
$ curl -XGET 'localhost:9200/_status' | json_reformat
{
"ok": true,
"_shards": {
"total": 20,
"successful": 10,
"failed": 0
},
"indices": {
"gems": {
"index": {
"primary_size": "495b",
"primary_size_in_bytes": 495,
"size": "495b",
"size_in_bytes": 495
},
...
Delete Index
$ curl -XDELETE 'http://localhost:9200/gems'
{
"ok":true,
"acknowledged":true
}
Create custom Index
{
"settings" : {
"index" : {
"number_of_shards" : 6,
"number_of_replicas" : 0
}
}
}
$ curl -XPUT 'http://localhost:9200/gems' -d @body.json
{
"ok":true,
"acknowledged":true
}
Index a document
{
"name": "pry",
"platform": "ruby",
"rubygems_version": "1.5.2",
"description": "attach an irb-like session to any object at runtime",
"email": "anurag@example.com",
"has_rdoc": true,
"homepage": "http://banisterfiend.wordpress.com"
}
$ curl -XPOST 'http://localhost:9200/gems/test/' -d @body.json
{
"ok":true,
"_index":"gems",
"_type":"test",
"_id":"lsJgxiwET6eg",
"_version":1
}
Get document
$ curl -XGET 'http://localhost:9200/gems/test/lsJgxiwET6eg' | python -mjson.tool
{
"_id": "lsJgxiwET6eg",
"_index": "gems",
"_source": {
"description": "attach an irb-like session to any object at runtime",
"email": "anurag@example.com",
"has_rdoc": true,
"homepage": "http://banisterfiend.wordpress.com",
"name": "pry",
"platform": "ruby",
"rubygems_version": "1.5.2"
},
"_type": "test",
"_version": 1,
"exists": true
}
Index another document
{
"name": "grit",
"platform": "jruby",
"rubygems_version": "2.5.0",
"description": "Ruby library for extracting information from a git repository.",
"email": "mojombo@github.com",
"has_rdoc": false,
"homepage": "http://github.com/mojombo/grit"
}
$ curl -XPOST 'http://localhost:9200/gems/test/' -d @body.json
{
"ok":true,
"_index":"gems",
"_type":"test",
"_id":"ijUOHi2cQc2",
"_version":1
}
Custom Document IDs
IDs are unique across Index. Composed of DocumentType and ID.
{
"name": "grit",
"platform": "jruby",
"rubygems_version": "2.5.1",
"description": "Ruby library for extracting information from a git repository.",
"email": "mojombo@github.com",
"has_rdoc": false,
"homepage": "http://github.com/mojombo/grit"
}
$ curl -XPUT 'http://localhost:9200/gems/test/grit-2.5.1' -d @body.json
{
"ok":true,
"_index":"gems",
"_type":"test",
"_id":"grit-2.5.1",
"_version":1
}
Document Versions
$ curl -XPUT 'http://localhost:9200/gems/test/grit-2.5.1' -d @body.json
{
"ok":true,
"_index":"gems",
"_type":"test",
"_id":"grit-2.5.1",
"_version":2
}
Searching Documents
{
"query": {
"term": {"name": "pry"}
}
}
$ curl -XPOST http://localhost:9200/gems/_search -d @body.json | python -mjson.tool
{
"_shards": {
"failed": 0,
"successful": 6,
"total": 6
},
"hits": {
"hits": [
{
"_id": "MWkKgzsMRgK",
"_index": "gems",
"_score": 1.4054651,
"_source": {
"description": "attach an irb-like session to any object at runtime",
"email": "anurag@example.com",
"has_rdoc": true,
"homepage": "http://banisterfiend.wordpress.com",
"name": "pry",
"platform": "ruby",
"rubygems_version": "1.5.2"
},
"_type": "test"
}
],
"max_score": 1.4054651,
"total": 1
Counting Documents
{
"term": {"name": "pry"}
}
$ curl -XGET http://localhost:9200/gems/test/_count -d @body.json
{
"_shards": {
"failed": 0,
"successful": 6,
"total": 6
},
"count": 1
}
Update a Document
The partial document is merged using simple recursive merge.
{
"doc": {
"platform": "macruby"
}
}
$ curl -XPOST http://localhost:9200/gems/test/grit-2.5.1/_update -d @body.json
{
"ok":true,
"_index":"gems",
"_type":"test",
"_id":"grit-2.5.1",
"_version":4
}
Update via Script
{
"script" : "ctx._source.platform = vm_name",
"params" : {
"vm_name" : "rubinius"
}
}
$ curl -XPOST http://localhost:9200/gems/test/grit-2.5.1/_update -d @body.json
{
"ok":true,
"_index":"gems",
"_type":"test",
"_id":"grit-2.5.1",
"_version":5
}
Delete Document
$ curl -XDELETE 'http://localhost:9200/gems/test/grit-2.5.1'
{
"ok":true,
"found":true,
"_index":"gems",
"_type":"test",
"_id":"grit-2.5.1",
"_version":6
}
Put Mapping
{
"gem" : {
"properties" : {
"name" : {"type" : "string", "index": "not_analyzed"},
"platform" : {"type" : "string", "index": "not_analyzed"},
"rubygems_version" : {"type" : "string", "index": "not_analyzed"},
"description" : {"type" : "string", "store" : "yes"},
"has_rdoc" : {"type" : "boolean"}
}
}
}
$ curl -XPUT 'http://localhost:9200/gems/gem/_mapping' -d @body.json
$ curl -XGET 'http://localhost:9200/gems/_mapping' | python -mjson.tool
Index Document with Mapping
{
"name": "grit",
"platform": "ruby",
"rubygems_version": "2.5.1",
"description": "Ruby library for extracting information from a git repository.",
"email": "mojombo@github.com",
"has_rdoc": false,
"homepage": "http://github.com/mojombo/grit"
}
$ curl -XPUT 'http://localhost:9200/gems/gem/grit-2.5.1' -d @body.json
{
"ok":true,
"_index":"gems",
"_type":"gem",
"_id":"grit-2.5.1",
"_version":1
}
Matching documents
{
"query": {
"match" : {
"description" : "git repository"
}
}
}
$ curl -XPOST http://localhost:9200/gems/gem/_search -d @body.json
Highlighting
{
"query": {
"match" : {
"description" : "git repository"
}
},
"highlight" : {
"fields" : {
"description" : {}
}
}
}
$ curl -XPOST http://localhost:9200/gems/gem/_search -d @body.json
"highlight": {
"description": [
"Ruby library for extracting information from a <em>git</em> <em>repository</em>."
]
}
Search Facets
{
"query": { "match_all" : {} },
"facets" : {
"gem_names" : {
"terms" : { "field": "name" }
}
}
}
$ curl -XPOST http://localhost:9200/gems/_search -d @body.json
...
"facets": {
"gem_names": {
"_type": "terms",
"missing": 0,
"other": 0,
"terms": [
{
"count": 2,
"term": "pry"
},
{
"count": 2,
"term": "grit"
},
{
"count": 1,
"term": "abc"
}
],
"total": 5
}
},
(Lab)
Analyzing Aadhaar's Datasets
Download Public Dataset
Download from Aadhaar Public Data Portal at
https://data.uidai.gov.in
Download Tools
$ git clone https://github.com/gnurag/aadhaar
Prepare Data & Configure
# gem install yajl-ruby tire activesupport
$ git clone https://github.com/gnurag/aadhaar
$ cd aadhaar/data
$ unzip UIDAI-ENR-DETAIL-20121001.zip
$ cd ../bin
$ vi aadhaar.rb
Configuration
AADHAAR_DATA_DIR = "/path/to/aadhaar/data"
ES_URL = "http://localhost:9200"
ES_INDEX = 'aadhaar'
ES_TYPE = "UID"
BATCH_SIZE = 1000
Index
$ ruby aadhaar.rb
Running Examples
$ curl -XPOST http://localhost:9200/aadhaar/UID/_search -d
@template.json | python -mjson.tool
Additional Notes
Index Aliases
Group multiple Indexes, and query them together.
curl -XPOST 'http://localhost:9200/_aliases' -d '
{
"actions" : [
{ "add" : { "index" : "index1", "alias" : "master-alias" } }
{ "add" : { "index" : "index2", "alias" : "master-alias" } }
]
}'
curl -XPOST 'http://localhost:9200/_aliases' -d '
{
"actions" : [
{ "remove" : { "index" : "index2", "alias" : "master-alias" } }
]
}'
Document Routing
Control which Shard the document will be placed and queried from.
Parents & Children
$ curl -XPUT http://localhost:9200/gems/gem/roxml?parent=rexml -d '{
"tag" : "something"
}'
Custom Analyzers
Boosting Search Results
ElasticSearch Ecosystem
A wide range of site plugins, analyzers, river plugins available from
the community.
THE END/@gnurag github

Mais conteúdo relacionado

Mais procurados

ElasticSearch Basic Introduction
ElasticSearch Basic IntroductionElasticSearch Basic Introduction
ElasticSearch Basic IntroductionMayur Rathod
 
Elasticsearch From the Bottom Up
Elasticsearch From the Bottom UpElasticsearch From the Bottom Up
Elasticsearch From the Bottom Upfoundsearch
 
Elasticsearch for Data Analytics
Elasticsearch for Data AnalyticsElasticsearch for Data Analytics
Elasticsearch for Data AnalyticsFelipe
 
Introduction to elasticsearch
Introduction to elasticsearchIntroduction to elasticsearch
Introduction to elasticsearchhypto
 
Elasticsearch presentation 1
Elasticsearch presentation 1Elasticsearch presentation 1
Elasticsearch presentation 1Maruf Hassan
 
Elastic search overview
Elastic search overviewElastic search overview
Elastic search overviewABC Talks
 
Elastic search Walkthrough
Elastic search WalkthroughElastic search Walkthrough
Elastic search WalkthroughSuhel Meman
 
Intro to elasticsearch
Intro to elasticsearchIntro to elasticsearch
Intro to elasticsearchJoey Wen
 
Introduction to Elasticsearch
Introduction to ElasticsearchIntroduction to Elasticsearch
Introduction to ElasticsearchIsmaeel Enjreny
 
Introduction à ElasticSearch
Introduction à ElasticSearchIntroduction à ElasticSearch
Introduction à ElasticSearchFadel Chafai
 
Elasticsearch for beginners
Elasticsearch for beginnersElasticsearch for beginners
Elasticsearch for beginnersNeil Baker
 
ElasticSearch : Architecture et Développement
ElasticSearch : Architecture et DéveloppementElasticSearch : Architecture et Développement
ElasticSearch : Architecture et DéveloppementMohamed hedi Abidi
 
Elastic Stack Introduction
Elastic Stack IntroductionElastic Stack Introduction
Elastic Stack IntroductionVikram Shinde
 

Mais procurados (20)

ElasticSearch Basic Introduction
ElasticSearch Basic IntroductionElasticSearch Basic Introduction
ElasticSearch Basic Introduction
 
Elasticsearch From the Bottom Up
Elasticsearch From the Bottom UpElasticsearch From the Bottom Up
Elasticsearch From the Bottom Up
 
Elasticsearch for Data Analytics
Elasticsearch for Data AnalyticsElasticsearch for Data Analytics
Elasticsearch for Data Analytics
 
Introduction to elasticsearch
Introduction to elasticsearchIntroduction to elasticsearch
Introduction to elasticsearch
 
Elasticsearch presentation 1
Elasticsearch presentation 1Elasticsearch presentation 1
Elasticsearch presentation 1
 
Elastic search overview
Elastic search overviewElastic search overview
Elastic search overview
 
Elastic search Walkthrough
Elastic search WalkthroughElastic search Walkthrough
Elastic search Walkthrough
 
Intro to elasticsearch
Intro to elasticsearchIntro to elasticsearch
Intro to elasticsearch
 
Elasticsearch Introduction
Elasticsearch IntroductionElasticsearch Introduction
Elasticsearch Introduction
 
Introduction to Elasticsearch
Introduction to ElasticsearchIntroduction to Elasticsearch
Introduction to Elasticsearch
 
Elasticsearch
ElasticsearchElasticsearch
Elasticsearch
 
Introduction à ElasticSearch
Introduction à ElasticSearchIntroduction à ElasticSearch
Introduction à ElasticSearch
 
Elasticsearch for beginners
Elasticsearch for beginnersElasticsearch for beginners
Elasticsearch for beginners
 
Elasticsearch
ElasticsearchElasticsearch
Elasticsearch
 
ElasticSearch : Architecture et Développement
ElasticSearch : Architecture et DéveloppementElasticSearch : Architecture et Développement
ElasticSearch : Architecture et Développement
 
ELK Stack
ELK StackELK Stack
ELK Stack
 
Elasticsearch
ElasticsearchElasticsearch
Elasticsearch
 
Elastic Stack Introduction
Elastic Stack IntroductionElastic Stack Introduction
Elastic Stack Introduction
 
Elasticsearch
ElasticsearchElasticsearch
Elasticsearch
 
elk_stack_alexander_szalonnas
elk_stack_alexander_szalonnaselk_stack_alexander_szalonnas
elk_stack_alexander_szalonnas
 

Destaque

Your Data, Your Search, ElasticSearch (EURUKO 2011)
Your Data, Your Search, ElasticSearch (EURUKO 2011)Your Data, Your Search, ElasticSearch (EURUKO 2011)
Your Data, Your Search, ElasticSearch (EURUKO 2011)Karel Minarik
 
Elasticsearch Query DSL - Not just for wizards...
Elasticsearch Query DSL - Not just for wizards...Elasticsearch Query DSL - Not just for wizards...
Elasticsearch Query DSL - Not just for wizards...clintongormley
 
What's new in Elasticsearch v5
What's new in Elasticsearch v5What's new in Elasticsearch v5
What's new in Elasticsearch v5Idan Tohami
 
Scaling real-time search and analytics with Elasticsearch
Scaling real-time search and analytics with ElasticsearchScaling real-time search and analytics with Elasticsearch
Scaling real-time search and analytics with Elasticsearchclintongormley
 
Elasticsearch in 15 minutes
Elasticsearch in 15 minutesElasticsearch in 15 minutes
Elasticsearch in 15 minutesDavid Pilato
 
Logging with Elasticsearch, Logstash & Kibana
Logging with Elasticsearch, Logstash & KibanaLogging with Elasticsearch, Logstash & Kibana
Logging with Elasticsearch, Logstash & KibanaAmazee Labs
 
使用 Elasticsearch 及 Kibana 進行巨量資料搜尋及視覺化-曾書庭
使用 Elasticsearch 及 Kibana 進行巨量資料搜尋及視覺化-曾書庭使用 Elasticsearch 及 Kibana 進行巨量資料搜尋及視覺化-曾書庭
使用 Elasticsearch 及 Kibana 進行巨量資料搜尋及視覺化-曾書庭台灣資料科學年會
 
Running High Performance and Fault Tolerant Elasticsearch Clusters on Docker
Running High Performance and Fault Tolerant Elasticsearch Clusters on DockerRunning High Performance and Fault Tolerant Elasticsearch Clusters on Docker
Running High Performance and Fault Tolerant Elasticsearch Clusters on DockerSematext Group, Inc.
 
Elasticsearch, the story so far
Elasticsearch, the story so farElasticsearch, the story so far
Elasticsearch, the story so farJordy Moos
 
HTML5, Websockets & the Mobile Web
HTML5, Websockets & the Mobile WebHTML5, Websockets & the Mobile Web
HTML5, Websockets & the Mobile WebDominique Guinard
 
Getting Started Of Elasticsearch
Getting Started Of ElasticsearchGetting Started Of Elasticsearch
Getting Started Of ElasticsearchMustafa Dağdelen
 
Unit Testing and Tools - ADNUG
Unit Testing and Tools - ADNUGUnit Testing and Tools - ADNUG
Unit Testing and Tools - ADNUGWilliam Simms
 
Introduction to Elasticsearch
Introduction to ElasticsearchIntroduction to Elasticsearch
Introduction to ElasticsearchJason Austin
 
Show me the problem- Our insights journey at Netflix
Show me the problem- Our insights journey at NetflixShow me the problem- Our insights journey at Netflix
Show me the problem- Our insights journey at NetflixSuudhan Rangarajan
 
Hadoop: Components and Key Ideas, -part1
Hadoop: Components and Key Ideas, -part1Hadoop: Components and Key Ideas, -part1
Hadoop: Components and Key Ideas, -part1Sandeep Kunkunuru
 

Destaque (20)

Your Data, Your Search, ElasticSearch (EURUKO 2011)
Your Data, Your Search, ElasticSearch (EURUKO 2011)Your Data, Your Search, ElasticSearch (EURUKO 2011)
Your Data, Your Search, ElasticSearch (EURUKO 2011)
 
Elasticsearch Query DSL - Not just for wizards...
Elasticsearch Query DSL - Not just for wizards...Elasticsearch Query DSL - Not just for wizards...
Elasticsearch Query DSL - Not just for wizards...
 
What's new in Elasticsearch v5
What's new in Elasticsearch v5What's new in Elasticsearch v5
What's new in Elasticsearch v5
 
Scaling real-time search and analytics with Elasticsearch
Scaling real-time search and analytics with ElasticsearchScaling real-time search and analytics with Elasticsearch
Scaling real-time search and analytics with Elasticsearch
 
Elasticsearch in 15 minutes
Elasticsearch in 15 minutesElasticsearch in 15 minutes
Elasticsearch in 15 minutes
 
Logging with Elasticsearch, Logstash & Kibana
Logging with Elasticsearch, Logstash & KibanaLogging with Elasticsearch, Logstash & Kibana
Logging with Elasticsearch, Logstash & Kibana
 
使用 Elasticsearch 及 Kibana 進行巨量資料搜尋及視覺化-曾書庭
使用 Elasticsearch 及 Kibana 進行巨量資料搜尋及視覺化-曾書庭使用 Elasticsearch 及 Kibana 進行巨量資料搜尋及視覺化-曾書庭
使用 Elasticsearch 及 Kibana 進行巨量資料搜尋及視覺化-曾書庭
 
Running High Performance and Fault Tolerant Elasticsearch Clusters on Docker
Running High Performance and Fault Tolerant Elasticsearch Clusters on DockerRunning High Performance and Fault Tolerant Elasticsearch Clusters on Docker
Running High Performance and Fault Tolerant Elasticsearch Clusters on Docker
 
Plack at OSCON 2010
Plack at OSCON 2010Plack at OSCON 2010
Plack at OSCON 2010
 
Elasticsearch, the story so far
Elasticsearch, the story so farElasticsearch, the story so far
Elasticsearch, the story so far
 
HTML5, Websockets & the Mobile Web
HTML5, Websockets & the Mobile WebHTML5, Websockets & the Mobile Web
HTML5, Websockets & the Mobile Web
 
Elasticsearch Workshop
Elasticsearch WorkshopElasticsearch Workshop
Elasticsearch Workshop
 
Campaign Technology
Campaign TechnologyCampaign Technology
Campaign Technology
 
Getting Started Of Elasticsearch
Getting Started Of ElasticsearchGetting Started Of Elasticsearch
Getting Started Of Elasticsearch
 
Unit Testing and Tools - ADNUG
Unit Testing and Tools - ADNUGUnit Testing and Tools - ADNUG
Unit Testing and Tools - ADNUG
 
Introduction to Elasticsearch
Introduction to ElasticsearchIntroduction to Elasticsearch
Introduction to Elasticsearch
 
Show me the problem- Our insights journey at Netflix
Show me the problem- Our insights journey at NetflixShow me the problem- Our insights journey at Netflix
Show me the problem- Our insights journey at Netflix
 
Hadoop 2.0 handout 5.0
Hadoop 2.0 handout 5.0Hadoop 2.0 handout 5.0
Hadoop 2.0 handout 5.0
 
Hadoop: Components and Key Ideas, -part1
Hadoop: Components and Key Ideas, -part1Hadoop: Components and Key Ideas, -part1
Hadoop: Components and Key Ideas, -part1
 
Elasticsearch 5.0
Elasticsearch 5.0Elasticsearch 5.0
Elasticsearch 5.0
 

Semelhante a Workshop: Learning Elasticsearch

Elasticsearch & "PeopleSearch"
Elasticsearch & "PeopleSearch"Elasticsearch & "PeopleSearch"
Elasticsearch & "PeopleSearch"George Stathis
 
Using ElasticSearch as a fast, flexible, and scalable solution to search occu...
Using ElasticSearch as a fast, flexible, and scalable solution to search occu...Using ElasticSearch as a fast, flexible, and scalable solution to search occu...
Using ElasticSearch as a fast, flexible, and scalable solution to search occu...kristgen
 
Null Bachaav - May 07 Attack Monitoring workshop.
Null Bachaav - May 07 Attack Monitoring workshop.Null Bachaav - May 07 Attack Monitoring workshop.
Null Bachaav - May 07 Attack Monitoring workshop.Prajal Kulkarni
 
[2D1]Elasticsearch 성능 최적화
[2D1]Elasticsearch 성능 최적화[2D1]Elasticsearch 성능 최적화
[2D1]Elasticsearch 성능 최적화NAVER D2
 
[2 d1] elasticsearch 성능 최적화
[2 d1] elasticsearch 성능 최적화[2 d1] elasticsearch 성능 최적화
[2 d1] elasticsearch 성능 최적화Henry Jeong
 
Voxxed Athens 2018 - Elasticsearch (R)Evolution — You Know, for Search...
Voxxed Athens 2018 - Elasticsearch (R)Evolution — You Know, for Search...Voxxed Athens 2018 - Elasticsearch (R)Evolution — You Know, for Search...
Voxxed Athens 2018 - Elasticsearch (R)Evolution — You Know, for Search...Voxxed Athens
 
Using elasticsearch with rails
Using elasticsearch with railsUsing elasticsearch with rails
Using elasticsearch with railsTom Z Zeng
 
Attack monitoring using ElasticSearch Logstash and Kibana
Attack monitoring using ElasticSearch Logstash and KibanaAttack monitoring using ElasticSearch Logstash and Kibana
Attack monitoring using ElasticSearch Logstash and KibanaPrajal Kulkarni
 
Java clients for elasticsearch
Java clients for elasticsearchJava clients for elasticsearch
Java clients for elasticsearchFlorian Hopf
 
Elasticsearch, a distributed search engine with real-time analytics
Elasticsearch, a distributed search engine with real-time analyticsElasticsearch, a distributed search engine with real-time analytics
Elasticsearch, a distributed search engine with real-time analyticsTiziano Fagni
 
quick intro to elastic search
quick intro to elastic search quick intro to elastic search
quick intro to elastic search medcl
 
Modernizing WordPress Search with Elasticsearch
Modernizing WordPress Search with ElasticsearchModernizing WordPress Search with Elasticsearch
Modernizing WordPress Search with ElasticsearchTaylor Lovett
 
Elastic search intro-@lamper
Elastic search intro-@lamperElastic search intro-@lamper
Elastic search intro-@lampermedcl
 
06 integrate elasticsearch
06 integrate elasticsearch06 integrate elasticsearch
06 integrate elasticsearchErhwen Kuo
 
曾勇 Elastic search-intro
曾勇 Elastic search-intro曾勇 Elastic search-intro
曾勇 Elastic search-introShaoning Pan
 
ElasticSearch for .NET Developers
ElasticSearch for .NET DevelopersElasticSearch for .NET Developers
ElasticSearch for .NET DevelopersBen van Mol
 
Elasticsearch, Logstash, Kibana. Cool search, analytics, data mining and more...
Elasticsearch, Logstash, Kibana. Cool search, analytics, data mining and more...Elasticsearch, Logstash, Kibana. Cool search, analytics, data mining and more...
Elasticsearch, Logstash, Kibana. Cool search, analytics, data mining and more...Oleksiy Panchenko
 
DevOps Fest 2019. Сергей Марченко. Terraform: a novel about modules, provider...
DevOps Fest 2019. Сергей Марченко. Terraform: a novel about modules, provider...DevOps Fest 2019. Сергей Марченко. Terraform: a novel about modules, provider...
DevOps Fest 2019. Сергей Марченко. Terraform: a novel about modules, provider...DevOps_Fest
 
Elasticsearch quick Intro (English)
Elasticsearch quick Intro (English)Elasticsearch quick Intro (English)
Elasticsearch quick Intro (English)Federico Panini
 

Semelhante a Workshop: Learning Elasticsearch (20)

Elasticsearch & "PeopleSearch"
Elasticsearch & "PeopleSearch"Elasticsearch & "PeopleSearch"
Elasticsearch & "PeopleSearch"
 
Using ElasticSearch as a fast, flexible, and scalable solution to search occu...
Using ElasticSearch as a fast, flexible, and scalable solution to search occu...Using ElasticSearch as a fast, flexible, and scalable solution to search occu...
Using ElasticSearch as a fast, flexible, and scalable solution to search occu...
 
Null Bachaav - May 07 Attack Monitoring workshop.
Null Bachaav - May 07 Attack Monitoring workshop.Null Bachaav - May 07 Attack Monitoring workshop.
Null Bachaav - May 07 Attack Monitoring workshop.
 
[2D1]Elasticsearch 성능 최적화
[2D1]Elasticsearch 성능 최적화[2D1]Elasticsearch 성능 최적화
[2D1]Elasticsearch 성능 최적화
 
[2 d1] elasticsearch 성능 최적화
[2 d1] elasticsearch 성능 최적화[2 d1] elasticsearch 성능 최적화
[2 d1] elasticsearch 성능 최적화
 
Voxxed Athens 2018 - Elasticsearch (R)Evolution — You Know, for Search...
Voxxed Athens 2018 - Elasticsearch (R)Evolution — You Know, for Search...Voxxed Athens 2018 - Elasticsearch (R)Evolution — You Know, for Search...
Voxxed Athens 2018 - Elasticsearch (R)Evolution — You Know, for Search...
 
Using elasticsearch with rails
Using elasticsearch with railsUsing elasticsearch with rails
Using elasticsearch with rails
 
Attack monitoring using ElasticSearch Logstash and Kibana
Attack monitoring using ElasticSearch Logstash and KibanaAttack monitoring using ElasticSearch Logstash and Kibana
Attack monitoring using ElasticSearch Logstash and Kibana
 
Java clients for elasticsearch
Java clients for elasticsearchJava clients for elasticsearch
Java clients for elasticsearch
 
Elasticsearch, a distributed search engine with real-time analytics
Elasticsearch, a distributed search engine with real-time analyticsElasticsearch, a distributed search engine with real-time analytics
Elasticsearch, a distributed search engine with real-time analytics
 
quick intro to elastic search
quick intro to elastic search quick intro to elastic search
quick intro to elastic search
 
Modernizing WordPress Search with Elasticsearch
Modernizing WordPress Search with ElasticsearchModernizing WordPress Search with Elasticsearch
Modernizing WordPress Search with Elasticsearch
 
Elastic search intro-@lamper
Elastic search intro-@lamperElastic search intro-@lamper
Elastic search intro-@lamper
 
06 integrate elasticsearch
06 integrate elasticsearch06 integrate elasticsearch
06 integrate elasticsearch
 
曾勇 Elastic search-intro
曾勇 Elastic search-intro曾勇 Elastic search-intro
曾勇 Elastic search-intro
 
ElasticSearch for .NET Developers
ElasticSearch for .NET DevelopersElasticSearch for .NET Developers
ElasticSearch for .NET Developers
 
Elasticsearch, Logstash, Kibana. Cool search, analytics, data mining and more...
Elasticsearch, Logstash, Kibana. Cool search, analytics, data mining and more...Elasticsearch, Logstash, Kibana. Cool search, analytics, data mining and more...
Elasticsearch, Logstash, Kibana. Cool search, analytics, data mining and more...
 
DevOps Fest 2019. Сергей Марченко. Terraform: a novel about modules, provider...
DevOps Fest 2019. Сергей Марченко. Terraform: a novel about modules, provider...DevOps Fest 2019. Сергей Марченко. Terraform: a novel about modules, provider...
DevOps Fest 2019. Сергей Марченко. Terraform: a novel about modules, provider...
 
Elastic search
Elastic searchElastic search
Elastic search
 
Elasticsearch quick Intro (English)
Elasticsearch quick Intro (English)Elasticsearch quick Intro (English)
Elasticsearch quick Intro (English)
 

Último

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 WorkerThousandEyes
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
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...Neo4j
 
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 CVKhem
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
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)wesley chun
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
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 RobisonAnna Loughnan Colquhoun
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 

Último (20)

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
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
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...
 
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
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
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)
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
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
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

Workshop: Learning Elasticsearch

  • 1. Learning ElasticSearch — Fifth Elephant 2013, Bangalore. Anurag Patel Red Hat
  • 3. ElasticWho? ElasticSearch is a flexible and powerful open source, distributed real-time search and analytics engine.
  • 4. Features Real time analytics Distributed High availability Multi tenant architecture Full text Document oriented Schema free RESTful API Per-operation persistence
  • 5. Distributed Start small and scale horizontally out of the box. For more capacity, just add more nodes and let the cluster reorganize itself.
  • 6. High Availability ElasticSearch clusters detect and remove failed nodes, and reorganize themselves.
  • 7. Multi Tenancy A cluster can host multiple indices which can be queried independently, or as a group. $ curl -XPUT http://localhost:9200/people $ curl -XPUT http://localhost:9200/gems $ curl -XPUT http://localhost:9200/gems/document/pry-0.5.9 $ curl -XGET http://localhost:9200/gems/document/pry-0.5.9
  • 8. Document Oriented Store complex real world entities in Elasticsearch as structured JSON documents. { "_id": "pry-0.5.9", "_index": "gems", "_source": { "authors": [ "John Mair (banisterfiend)" ], "autorequire": null, "bindir": "bin", "cert_chain": [], "date": "Sun Feb 20 11:00:00 UTC 2011", "default_executable": null, "description": "attach an irb-like session to any object at runtime", "email": "jrmair@gmail.com" } }
  • 9. RESTful API Almost any operation can be performed using a simple RESTful interface using JSON over HTTP. curl -X GET curl -X PUT curl -X POST curl -X DELETE
  • 10. Apache Lucene ElasticSearch is built on top of Apache Lucene. Lucene is a high performance, full-featured Information Retrieval library, written in Java.
  • 12. Document $ curl -XGET http://localhost:9200/gems/document/pry-0.5.9 In ElasticSearch, everything is stored as a Document. Document can be addressed and retrieved by querying their attributes. { "_id": "pry-0.5.9", "_index": "gems", "_source": { "authors": [ "John Mair (banisterfiend)" ], "autorequire": null, "bindir": "bin", "cert_chain": [], "date": "Sun Feb 20 11:00:00 UTC 2011", "default_executable": null, "description": "attach an irb-like session to any object at runtime", "email": "jrmair@gmail.com", "executables": [ "pry" ], "extensions": [], "extra_rdoc_files": [], "files": [ "lib/pry/commands.rb", "lib/pry/command_base.rb", "lib/pry/completion.rb", "lib/pry/core_extensions.rb", "lib/pry/hooks.rb", "lib/pry/print.rb", "lib/pry/prompts.rb", "lib/pry/pry_class.rb", "lib/pry/pry_instance.rb", "lib/pry/version.rb", "lib/pry.rb", "examples/example_basic.rb",
  • 13. Document Types Lets us specify document properties, so we can differentiate the objects.
  • 14. Shard Each Shard is a separate native Lucene Index. Lets us overcome RAM limitations, hard disk capacity.
  • 15. Replica An exact copy of primary Shard. Helps in setting up HA, increases query throughput.
  • 16. Index ElasticSearch stores its data in logical Indices. Think of a table, collection or a database. An Index has atleast 1 primary Shard, and 0 or more Replicas.
  • 17. Cluster A collection of cooperating ElasticSearch nodes. Gives better availability and performance via Index Sharding and Replicas.
  • 19. Download and start Download ElasticSearch from http://www.elasticsearch.org/download # service elasticsearch start # /etc/init.d/elasticsearch start # ./bin/elasticsearch -f
  • 20. ElasticSearch Plugins A site plugin to view contents of ElasticSearch cluster. Restart ElasticSearch. Plugins are detected and loaded on service startup. # cd /usr/share/elasticsearch # ./bin/plugin -install mobz/elasticsearch-head # cd /opt/elasticsearch-0.90.2 # ./bin/plugin -install mobz/elasticsearch-head
  • 22. RESTful interface $ curl -XGET 'http://localhost:9200/' { "ok" : true, "status" : 200, "name" : "Drake, Frank", "version" : { "number" : "0.90.2", "snapshot_build" : false, "lucene_version" : "4.3.1" }, "tagline" : "You Know, for Search" }
  • 23. Create Index $ curl -XPUT 'http://localhost:9200/gems' { "ok":true, "acknowledged":true }
  • 24. Cluster status $ curl -XGET 'localhost:9200/_status' {"ok":true,"_shards":{"total":20,"successful":10,"failed":0}, "indices":{"gems":{"index":{"primary_size":"495b","primary_size_in_bytes":495, "size":"495b","size_in_bytes":495},"translog":{"operations":0}, "docs":{"num_docs":0,"max_doc":0,"deleted_docs":0},"merges": {"current":0,"current_docs":0,"current_size":"0b","current_size_in_bytes":0, "total":0,"total_time":"0s","total_time_in_millis":0,"total_docs":0, "total_size":"0b","total_size_in_bytes":0}, ... ... ...
  • 25. Pretty Output $ curl -XGET 'localhost:9200/_status?pretty' $ curl -XGET 'localhost:9200/_status' | python -mjson.tool $ curl -XGET 'localhost:9200/_status' | json_reformat { "ok": true, "_shards": { "total": 20, "successful": 10, "failed": 0 }, "indices": { "gems": { "index": { "primary_size": "495b", "primary_size_in_bytes": 495, "size": "495b", "size_in_bytes": 495 }, ...
  • 26. Delete Index $ curl -XDELETE 'http://localhost:9200/gems' { "ok":true, "acknowledged":true }
  • 27. Create custom Index { "settings" : { "index" : { "number_of_shards" : 6, "number_of_replicas" : 0 } } } $ curl -XPUT 'http://localhost:9200/gems' -d @body.json { "ok":true, "acknowledged":true }
  • 28. Index a document { "name": "pry", "platform": "ruby", "rubygems_version": "1.5.2", "description": "attach an irb-like session to any object at runtime", "email": "anurag@example.com", "has_rdoc": true, "homepage": "http://banisterfiend.wordpress.com" } $ curl -XPOST 'http://localhost:9200/gems/test/' -d @body.json { "ok":true, "_index":"gems", "_type":"test", "_id":"lsJgxiwET6eg", "_version":1 }
  • 29. Get document $ curl -XGET 'http://localhost:9200/gems/test/lsJgxiwET6eg' | python -mjson.tool { "_id": "lsJgxiwET6eg", "_index": "gems", "_source": { "description": "attach an irb-like session to any object at runtime", "email": "anurag@example.com", "has_rdoc": true, "homepage": "http://banisterfiend.wordpress.com", "name": "pry", "platform": "ruby", "rubygems_version": "1.5.2" }, "_type": "test", "_version": 1, "exists": true }
  • 30. Index another document { "name": "grit", "platform": "jruby", "rubygems_version": "2.5.0", "description": "Ruby library for extracting information from a git repository.", "email": "mojombo@github.com", "has_rdoc": false, "homepage": "http://github.com/mojombo/grit" } $ curl -XPOST 'http://localhost:9200/gems/test/' -d @body.json { "ok":true, "_index":"gems", "_type":"test", "_id":"ijUOHi2cQc2", "_version":1 }
  • 31. Custom Document IDs IDs are unique across Index. Composed of DocumentType and ID. { "name": "grit", "platform": "jruby", "rubygems_version": "2.5.1", "description": "Ruby library for extracting information from a git repository.", "email": "mojombo@github.com", "has_rdoc": false, "homepage": "http://github.com/mojombo/grit" } $ curl -XPUT 'http://localhost:9200/gems/test/grit-2.5.1' -d @body.json { "ok":true, "_index":"gems", "_type":"test", "_id":"grit-2.5.1", "_version":1 }
  • 32. Document Versions $ curl -XPUT 'http://localhost:9200/gems/test/grit-2.5.1' -d @body.json { "ok":true, "_index":"gems", "_type":"test", "_id":"grit-2.5.1", "_version":2 }
  • 33. Searching Documents { "query": { "term": {"name": "pry"} } } $ curl -XPOST http://localhost:9200/gems/_search -d @body.json | python -mjson.tool { "_shards": { "failed": 0, "successful": 6, "total": 6 }, "hits": { "hits": [ { "_id": "MWkKgzsMRgK", "_index": "gems", "_score": 1.4054651, "_source": { "description": "attach an irb-like session to any object at runtime", "email": "anurag@example.com", "has_rdoc": true, "homepage": "http://banisterfiend.wordpress.com", "name": "pry", "platform": "ruby", "rubygems_version": "1.5.2" }, "_type": "test" } ], "max_score": 1.4054651, "total": 1
  • 34. Counting Documents { "term": {"name": "pry"} } $ curl -XGET http://localhost:9200/gems/test/_count -d @body.json { "_shards": { "failed": 0, "successful": 6, "total": 6 }, "count": 1 }
  • 35. Update a Document The partial document is merged using simple recursive merge. { "doc": { "platform": "macruby" } } $ curl -XPOST http://localhost:9200/gems/test/grit-2.5.1/_update -d @body.json { "ok":true, "_index":"gems", "_type":"test", "_id":"grit-2.5.1", "_version":4 }
  • 36. Update via Script { "script" : "ctx._source.platform = vm_name", "params" : { "vm_name" : "rubinius" } } $ curl -XPOST http://localhost:9200/gems/test/grit-2.5.1/_update -d @body.json { "ok":true, "_index":"gems", "_type":"test", "_id":"grit-2.5.1", "_version":5 }
  • 37. Delete Document $ curl -XDELETE 'http://localhost:9200/gems/test/grit-2.5.1' { "ok":true, "found":true, "_index":"gems", "_type":"test", "_id":"grit-2.5.1", "_version":6 }
  • 38. Put Mapping { "gem" : { "properties" : { "name" : {"type" : "string", "index": "not_analyzed"}, "platform" : {"type" : "string", "index": "not_analyzed"}, "rubygems_version" : {"type" : "string", "index": "not_analyzed"}, "description" : {"type" : "string", "store" : "yes"}, "has_rdoc" : {"type" : "boolean"} } } } $ curl -XPUT 'http://localhost:9200/gems/gem/_mapping' -d @body.json $ curl -XGET 'http://localhost:9200/gems/_mapping' | python -mjson.tool
  • 39. Index Document with Mapping { "name": "grit", "platform": "ruby", "rubygems_version": "2.5.1", "description": "Ruby library for extracting information from a git repository.", "email": "mojombo@github.com", "has_rdoc": false, "homepage": "http://github.com/mojombo/grit" } $ curl -XPUT 'http://localhost:9200/gems/gem/grit-2.5.1' -d @body.json { "ok":true, "_index":"gems", "_type":"gem", "_id":"grit-2.5.1", "_version":1 }
  • 40. Matching documents { "query": { "match" : { "description" : "git repository" } } } $ curl -XPOST http://localhost:9200/gems/gem/_search -d @body.json
  • 41. Highlighting { "query": { "match" : { "description" : "git repository" } }, "highlight" : { "fields" : { "description" : {} } } } $ curl -XPOST http://localhost:9200/gems/gem/_search -d @body.json "highlight": { "description": [ "Ruby library for extracting information from a <em>git</em> <em>repository</em>." ] }
  • 42. Search Facets { "query": { "match_all" : {} }, "facets" : { "gem_names" : { "terms" : { "field": "name" } } } } $ curl -XPOST http://localhost:9200/gems/_search -d @body.json ... "facets": { "gem_names": { "_type": "terms", "missing": 0, "other": 0, "terms": [ { "count": 2, "term": "pry" }, { "count": 2, "term": "grit" }, { "count": 1, "term": "abc" } ], "total": 5 } },
  • 44. Download Public Dataset Download from Aadhaar Public Data Portal at https://data.uidai.gov.in
  • 45. Download Tools $ git clone https://github.com/gnurag/aadhaar
  • 46. Prepare Data & Configure # gem install yajl-ruby tire activesupport $ git clone https://github.com/gnurag/aadhaar $ cd aadhaar/data $ unzip UIDAI-ENR-DETAIL-20121001.zip $ cd ../bin $ vi aadhaar.rb
  • 47. Configuration AADHAAR_DATA_DIR = "/path/to/aadhaar/data" ES_URL = "http://localhost:9200" ES_INDEX = 'aadhaar' ES_TYPE = "UID" BATCH_SIZE = 1000
  • 49. Running Examples $ curl -XPOST http://localhost:9200/aadhaar/UID/_search -d @template.json | python -mjson.tool
  • 51. Index Aliases Group multiple Indexes, and query them together. curl -XPOST 'http://localhost:9200/_aliases' -d ' { "actions" : [ { "add" : { "index" : "index1", "alias" : "master-alias" } } { "add" : { "index" : "index2", "alias" : "master-alias" } } ] }' curl -XPOST 'http://localhost:9200/_aliases' -d ' { "actions" : [ { "remove" : { "index" : "index2", "alias" : "master-alias" } } ] }'
  • 52. Document Routing Control which Shard the document will be placed and queried from.
  • 53. Parents & Children $ curl -XPUT http://localhost:9200/gems/gem/roxml?parent=rexml -d '{ "tag" : "something" }'
  • 56. ElasticSearch Ecosystem A wide range of site plugins, analyzers, river plugins available from the community.