SlideShare ist ein Scribd-Unternehmen logo
1 von 23
ElasticSearch



Presented by:
Abuzar Hasan
Arkhitech <http://www.arkhitech.com>
History


Shay Baron




Compass in 2004
ElasticSearch in 2010






Written in Java
Cross-platform
Distributed
Users








StumbleUpon
Mozilla
Github

Foursquare
Features


Distributed and Highly Available Search Engine










Each index is fully sharded with a configurable number of shards
Each shard can have one or more replicas
Read / Search operations performed on either one of the replica
shard

Multi Tenant with Multi Types
Various set of APIs
Features


Document Oriented
No need for upfront schema definition






(Near) Real Time Search
Per-Operation Persistence


Single document level operations are atomic, consistent, isolated
and durable
Features


Built on top of Lucene








Each shard is a fully functional Lucene index
All the power of Lucene easily exposed through simple
configuration / plugins
Independent of file format

Open Source under Apache 2 License
Setting Up Elastic Search


Download ElasticSearch (CentOS)
sudo yum install elasticsearch




Start ElasticSearch Server


elasticsearch -f -D
es.config=/usr/local/Cellar/elasticsearch/0.18.5/config/elasticsear
ch.yml
Setting up ElasticSearch w/
Ruby




The ElasticSearch is not ruby specific so 'tire' gem helps ruby
based projects to communicate with ElasticSearch
'tire' gem
https://github.com/karmi/retire




We then need to require following libraries




require 'rubygems'
require 'tire'
Indexing Records




Indexing includes both “Create” and “Update” in CRUD.
In order to make index request for new JSON object, we pass
the following URL


http://localhost:<port>/<index>/<type>/[<id>].
Indexing




Creating an index
curl -XPUT "http://localhost:9200/movies/movie/1" -d'
{


"title": "The Godfather",
"director": "Francis Ford Coppola",
"year": 1972








}'
Indexing Response


After executing the request, we get the following response
{














}

“ok”:
“_index”:
“_type”:
“_id”:
“_version”:

true,
“movies”,
“movie”,
“1”,
1
Retrieving Index


Retrieving the index


curl -XGET "http://localhost:9200/movies/movie/1" -d''
Retrieve Index Response
{














“_index”:
“_type”:
“_id”:
“_version”:
“exists”:
“_source”:










}

}

“movies”,
“movie”,
“1”,
1,
true,
{

"title": "The Godfather",
"director": "Francis Ford Coppola",
"year": 1972
Delete Index


Deleting the index


curl -XDELETE "http://localhost:9200/movies/movie/1" -d''
Demo Application


Demo Application by karmi


$ rails new searchapp -m
https://raw.github.com/karmi/tire/master/exam les/railsapplication-template.rb
Demo: Search App - Model


Model
include Tire::Model::Search
include Tire::Model::Callbacks








These two 'tire' models allow your rails application to use tire
gem for searching purposes
Demo: Search App
- Controller


Controller




@articles = Article.tire.search params[:query]

This line in your search method helps to search using tire gem
Demo: Search App - View


View









<%= form_tag search_articles_path, method: :get do %>
<%= text_field_tag :q, params[:query] %>
<%= submit_tag :search %>
<% end %>
Demo: Search App - Index


Create an index


















Tire.index 'articles' do
delete
create
store :title => 'One', :tags => ['ruby']
store :title => 'Two', :tags => ['ruby', 'python']
store :title => 'Three', :tags => ['java']
store :title => 'Four', :tags => ['ruby', 'php']
refresh
end
Demo: Search App - Index


For custom mapping
Tire.index 'articles' do


delete
create :mappings => {
:article => {
:properties => {
:id
=> { :type => 'string', :index => 'not_analyzed', :include_in_all => false },
:title => { :type => 'string', :boost => 2.0, :analyzer => 'snowball' },
:tags => { :type => 'string', :analyzer => 'keyword' },
:content => { :type => 'string', :analyzer => 'snowball' }
}
}





















}




end
Demo: Search App – Bulk
Indexing




For indexing large amount of data
articles = [












{ :id => '1', :type => 'article', :title => 'one', :tags => ['ruby'] },
{ :id => '2', :type => 'article', :title => 'two', :tags => ['ruby', 'python'] },
{ :id => '3', :type => 'article', :title => 'three', :tags => ['java'] },
{ :id => '4', :type => 'article', :title => 'four', :tags => ['ruby', 'php'] }

]
Use Import






Tire.index 'articles' do
import articles
end
Displaying Facets


For displaying facets
s.results.facets['global-tags']['terms'].each do |f|








puts "#{f['term'].ljust(10)} #{f['count']}"

end

Output








ruby
python
php
java

3
1
1
1
References
• https://github.com/karmi/retire
• http://railscasts.com/episodes/306-elasticsearch-part1

QUESTIONS?

Weitere ähnliche Inhalte

Was ist angesagt?

CakeFest 2013 - A-Z REST APIs
CakeFest 2013 - A-Z REST APIsCakeFest 2013 - A-Z REST APIs
CakeFest 2013 - A-Z REST APIs
anthony_putignano
 
Enterprise search in_drupal_pub
Enterprise search in_drupal_pubEnterprise search in_drupal_pub
Enterprise search in_drupal_pub
dstuartnz
 
Lucene for Solr Developers
Lucene for Solr DevelopersLucene for Solr Developers
Lucene for Solr Developers
Erik Hatcher
 

Was ist angesagt? (20)

Stop Hacking WordPress, Start Working with it - Charly Leetham - WordCamp Syd...
Stop Hacking WordPress, Start Working with it - Charly Leetham - WordCamp Syd...Stop Hacking WordPress, Start Working with it - Charly Leetham - WordCamp Syd...
Stop Hacking WordPress, Start Working with it - Charly Leetham - WordCamp Syd...
 
Web services with laravel
Web services with laravelWeb services with laravel
Web services with laravel
 
เกี่ยวกับ Apache solr 4.0
เกี่ยวกับ Apache solr 4.0เกี่ยวกับ Apache solr 4.0
เกี่ยวกับ Apache solr 4.0
 
An introduction to Laravel Passport
An introduction to Laravel PassportAn introduction to Laravel Passport
An introduction to Laravel Passport
 
ACL in CodeIgniter
ACL in CodeIgniterACL in CodeIgniter
ACL in CodeIgniter
 
Djangocon 2014 angular + django
Djangocon 2014 angular + djangoDjangocon 2014 angular + django
Djangocon 2014 angular + django
 
Action Bar Sherlock tutorial
Action Bar Sherlock tutorialAction Bar Sherlock tutorial
Action Bar Sherlock tutorial
 
Cusomizing Burp Suite - Getting the Most out of Burp Extensions
Cusomizing Burp Suite - Getting the Most out of Burp ExtensionsCusomizing Burp Suite - Getting the Most out of Burp Extensions
Cusomizing Burp Suite - Getting the Most out of Burp Extensions
 
CakeFest 2013 - A-Z REST APIs
CakeFest 2013 - A-Z REST APIsCakeFest 2013 - A-Z REST APIs
CakeFest 2013 - A-Z REST APIs
 
Python tools for testing web services over HTTP
Python tools for testing web services over HTTPPython tools for testing web services over HTTP
Python tools for testing web services over HTTP
 
Rails3 changesets
Rails3 changesetsRails3 changesets
Rails3 changesets
 
Designing CakePHP plugins for consuming APIs
Designing CakePHP plugins for consuming APIsDesigning CakePHP plugins for consuming APIs
Designing CakePHP plugins for consuming APIs
 
Lucene for Solr Developers
Lucene for Solr DevelopersLucene for Solr Developers
Lucene for Solr Developers
 
ActionBar and Holo in Android 2+
ActionBar and Holo in Android 2+ActionBar and Holo in Android 2+
ActionBar and Holo in Android 2+
 
REST Easy with Django-Rest-Framework
REST Easy with Django-Rest-FrameworkREST Easy with Django-Rest-Framework
REST Easy with Django-Rest-Framework
 
OSCON Google App Engine Codelab - July 2010
OSCON Google App Engine Codelab - July 2010OSCON Google App Engine Codelab - July 2010
OSCON Google App Engine Codelab - July 2010
 
Enterprise search in_drupal_pub
Enterprise search in_drupal_pubEnterprise search in_drupal_pub
Enterprise search in_drupal_pub
 
Lucene for Solr Developers
Lucene for Solr DevelopersLucene for Solr Developers
Lucene for Solr Developers
 
Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5
 
Rails 3 Beautiful Code
Rails 3 Beautiful CodeRails 3 Beautiful Code
Rails 3 Beautiful Code
 

Andere mochten auch

Mentoring I
Mentoring IMentoring I
Mentoring I
shendin
 
Xaneiro 2015
Xaneiro 2015Xaneiro 2015
Xaneiro 2015
iesasorey
 
Scan, Focus, Act
Scan, Focus, ActScan, Focus, Act
Scan, Focus, Act
easleyme
 
As noções de erro e fracasso no contexto escolar: algumas considerações preli...
As noções de erro e fracasso no contexto escolar: algumas considerações preli...As noções de erro e fracasso no contexto escolar: algumas considerações preli...
As noções de erro e fracasso no contexto escolar: algumas considerações preli...
Jefjac
 

Andere mochten auch (20)

QMiner - Data analytics platform for processing large-scale real-time stream...
 QMiner - Data analytics platform for processing large-scale real-time stream... QMiner - Data analytics platform for processing large-scale real-time stream...
QMiner - Data analytics platform for processing large-scale real-time stream...
 
Hi, today i present you five famous
Hi, today i present you five famousHi, today i present you five famous
Hi, today i present you five famous
 
Mentoring I
Mentoring IMentoring I
Mentoring I
 
Factura
FacturaFactura
Factura
 
碳酸鈉81027
碳酸鈉81027碳酸鈉81027
碳酸鈉81027
 
Factors that influence path to purchase
Factors that influence path to purchaseFactors that influence path to purchase
Factors that influence path to purchase
 
Xaneiro 2015
Xaneiro 2015Xaneiro 2015
Xaneiro 2015
 
Xander santiago 7 b
Xander santiago 7 bXander santiago 7 b
Xander santiago 7 b
 
Presentación sobre Diabetes
Presentación sobre DiabetesPresentación sobre Diabetes
Presentación sobre Diabetes
 
HP LaserJet Pro P1606dn – CE278A Toner Replacement
HP LaserJet Pro P1606dn – CE278A Toner ReplacementHP LaserJet Pro P1606dn – CE278A Toner Replacement
HP LaserJet Pro P1606dn – CE278A Toner Replacement
 
WordPress Theme & Plugin development best practices - phpXperts seminar 2011
WordPress Theme & Plugin development best practices - phpXperts seminar 2011WordPress Theme & Plugin development best practices - phpXperts seminar 2011
WordPress Theme & Plugin development best practices - phpXperts seminar 2011
 
Why Tablets? | 2011
Why Tablets? | 2011Why Tablets? | 2011
Why Tablets? | 2011
 
HAPPYWEEK 202 - 2017.01.16.
HAPPYWEEK 202 - 2017.01.16.HAPPYWEEK 202 - 2017.01.16.
HAPPYWEEK 202 - 2017.01.16.
 
Чингэлтэй дүүргийн 9 дүгээр хороо Дэнжийн 1000-ийн дахин төлөвлөлт
Чингэлтэй дүүргийн 9 дүгээр хороо Дэнжийн 1000-ийн дахин төлөвлөлтЧингэлтэй дүүргийн 9 дүгээр хороо Дэнжийн 1000-ийн дахин төлөвлөлт
Чингэлтэй дүүргийн 9 дүгээр хороо Дэнжийн 1000-ийн дахин төлөвлөлт
 
Scan, Focus, Act
Scan, Focus, ActScan, Focus, Act
Scan, Focus, Act
 
As noções de erro e fracasso no contexto escolar: algumas considerações preli...
As noções de erro e fracasso no contexto escolar: algumas considerações preli...As noções de erro e fracasso no contexto escolar: algumas considerações preli...
As noções de erro e fracasso no contexto escolar: algumas considerações preli...
 
Avaliação
AvaliaçãoAvaliação
Avaliação
 
12 Questions to Ask When Making a Content Marketing Technology Decision
12 Questions to Ask When Making a Content Marketing Technology Decision12 Questions to Ask When Making a Content Marketing Technology Decision
12 Questions to Ask When Making a Content Marketing Technology Decision
 
The Science of Gratitude
The Science of Gratitude The Science of Gratitude
The Science of Gratitude
 
4 Model Kepribadian ( D I S C)
4 Model Kepribadian ( D I S C)4 Model Kepribadian ( D I S C)
4 Model Kepribadian ( D I S C)
 

Ähnlich wie Introduction to ElasticSearch

Search Engine Capabilities - Apache Solr(Lucene)
Search Engine Capabilities - Apache Solr(Lucene)Search Engine Capabilities - Apache Solr(Lucene)
Search Engine Capabilities - Apache Solr(Lucene)
Manish kumar
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
Fabio Franzini
 
Ako prepojiť aplikáciu s Elasticsearch
Ako prepojiť aplikáciu s ElasticsearchAko prepojiť aplikáciu s Elasticsearch
Ako prepojiť aplikáciu s Elasticsearch
bart-sk
 
Rapid Prototyping with Solr
Rapid Prototyping with SolrRapid Prototyping with Solr
Rapid Prototyping with Solr
Erik Hatcher
 

Ähnlich wie Introduction to ElasticSearch (20)

Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
 
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
 
Apache Lucene Searching The Web
Apache Lucene Searching The WebApache Lucene Searching The Web
Apache Lucene Searching The Web
 
Apache Lucene: Searching the Web and Everything Else (Jazoon07)
Apache Lucene: Searching the Web and Everything Else (Jazoon07)Apache Lucene: Searching the Web and Everything Else (Jazoon07)
Apache Lucene: Searching the Web and Everything Else (Jazoon07)
 
Mastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium SuccessfullyMastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium Successfully
 
Prototyping applications with heroku and elasticsearch
 Prototyping applications with heroku and elasticsearch Prototyping applications with heroku and elasticsearch
Prototyping applications with heroku and elasticsearch
 
SCR Annotations for Fun and Profit
SCR Annotations for Fun and ProfitSCR Annotations for Fun and Profit
SCR Annotations for Fun and Profit
 
Search Engine Capabilities - Apache Solr(Lucene)
Search Engine Capabilities - Apache Solr(Lucene)Search Engine Capabilities - Apache Solr(Lucene)
Search Engine Capabilities - Apache Solr(Lucene)
 
[2D1]Elasticsearch 성능 최적화
[2D1]Elasticsearch 성능 최적화[2D1]Elasticsearch 성능 최적화
[2D1]Elasticsearch 성능 최적화
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
 
[2 d1] elasticsearch 성능 최적화
[2 d1] elasticsearch 성능 최적화[2 d1] elasticsearch 성능 최적화
[2 d1] elasticsearch 성능 최적화
 
Tips for Angular Applications
Tips for Angular ApplicationsTips for Angular Applications
Tips for Angular Applications
 
Adding High Performance Search to your Grails App
Adding High Performance Search to your Grails AppAdding High Performance Search to your Grails App
Adding High Performance Search to your Grails App
 
Ako prepojiť aplikáciu s Elasticsearch
Ako prepojiť aplikáciu s ElasticsearchAko prepojiť aplikáciu s Elasticsearch
Ako prepojiť aplikáciu s Elasticsearch
 
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
 
Rapid Prototyping with Solr
Rapid Prototyping with SolrRapid Prototyping with Solr
Rapid Prototyping with Solr
 
Using Thinking Sphinx with rails
Using Thinking Sphinx with railsUsing Thinking Sphinx with rails
Using Thinking Sphinx with rails
 
iOS Swift application architecture
iOS Swift application architectureiOS Swift application architecture
iOS Swift application architecture
 
Android search
Android searchAndroid search
Android search
 
Android search
Android searchAndroid search
Android search
 

Kürzlich hochgeladen

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Kürzlich hochgeladen (20)

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
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
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
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, ...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
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...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
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
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
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
 

Introduction to ElasticSearch

  • 2. History  Shay Baron   Compass in 2004 ElasticSearch in 2010    Written in Java Cross-platform Distributed
  • 4. Features  Distributed and Highly Available Search Engine      Each index is fully sharded with a configurable number of shards Each shard can have one or more replicas Read / Search operations performed on either one of the replica shard Multi Tenant with Multi Types Various set of APIs
  • 5. Features  Document Oriented No need for upfront schema definition    (Near) Real Time Search Per-Operation Persistence  Single document level operations are atomic, consistent, isolated and durable
  • 6. Features  Built on top of Lucene     Each shard is a fully functional Lucene index All the power of Lucene easily exposed through simple configuration / plugins Independent of file format Open Source under Apache 2 License
  • 7. Setting Up Elastic Search  Download ElasticSearch (CentOS) sudo yum install elasticsearch   Start ElasticSearch Server  elasticsearch -f -D es.config=/usr/local/Cellar/elasticsearch/0.18.5/config/elasticsear ch.yml
  • 8. Setting up ElasticSearch w/ Ruby   The ElasticSearch is not ruby specific so 'tire' gem helps ruby based projects to communicate with ElasticSearch 'tire' gem https://github.com/karmi/retire   We then need to require following libraries   require 'rubygems' require 'tire'
  • 9. Indexing Records   Indexing includes both “Create” and “Update” in CRUD. In order to make index request for new JSON object, we pass the following URL  http://localhost:<port>/<index>/<type>/[<id>].
  • 10. Indexing   Creating an index curl -XPUT "http://localhost:9200/movies/movie/1" -d' {  "title": "The Godfather", "director": "Francis Ford Coppola", "year": 1972     }'
  • 11. Indexing Response  After executing the request, we get the following response {        } “ok”: “_index”: “_type”: “_id”: “_version”: true, “movies”, “movie”, “1”, 1
  • 12. Retrieving Index  Retrieving the index  curl -XGET "http://localhost:9200/movies/movie/1" -d''
  • 14. Delete Index  Deleting the index  curl -XDELETE "http://localhost:9200/movies/movie/1" -d''
  • 15. Demo Application  Demo Application by karmi  $ rails new searchapp -m https://raw.github.com/karmi/tire/master/exam les/railsapplication-template.rb
  • 16. Demo: Search App - Model  Model include Tire::Model::Search include Tire::Model::Callbacks     These two 'tire' models allow your rails application to use tire gem for searching purposes
  • 17. Demo: Search App - Controller  Controller   @articles = Article.tire.search params[:query] This line in your search method helps to search using tire gem
  • 18. Demo: Search App - View  View     <%= form_tag search_articles_path, method: :get do %> <%= text_field_tag :q, params[:query] %> <%= submit_tag :search %> <% end %>
  • 19. Demo: Search App - Index  Create an index          Tire.index 'articles' do delete create store :title => 'One', :tags => ['ruby'] store :title => 'Two', :tags => ['ruby', 'python'] store :title => 'Three', :tags => ['java'] store :title => 'Four', :tags => ['ruby', 'php'] refresh end
  • 20. Demo: Search App - Index  For custom mapping Tire.index 'articles' do  delete create :mappings => { :article => { :properties => { :id => { :type => 'string', :index => 'not_analyzed', :include_in_all => false }, :title => { :type => 'string', :boost => 2.0, :analyzer => 'snowball' }, :tags => { :type => 'string', :analyzer => 'keyword' }, :content => { :type => 'string', :analyzer => 'snowball' } } }           }   end
  • 21. Demo: Search App – Bulk Indexing   For indexing large amount of data articles = [       { :id => '1', :type => 'article', :title => 'one', :tags => ['ruby'] }, { :id => '2', :type => 'article', :title => 'two', :tags => ['ruby', 'python'] }, { :id => '3', :type => 'article', :title => 'three', :tags => ['java'] }, { :id => '4', :type => 'article', :title => 'four', :tags => ['ruby', 'php'] } ] Use Import    Tire.index 'articles' do import articles end
  • 22. Displaying Facets  For displaying facets s.results.facets['global-tags']['terms'].each do |f|     puts "#{f['term'].ljust(10)} #{f['count']}" end Output     ruby python php java 3 1 1 1