Ce diaporama a bien été signalé.
Le téléchargement de votre SlideShare est en cours. ×

01 ElasticSearch : Getting Started

Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Chargement dans…3
×

Consultez-les par la suite

1 sur 19 Publicité

Plus De Contenu Connexe

Diaporamas pour vous (20)

Similaire à 01 ElasticSearch : Getting Started (20)

Publicité

Plus par OpenThink Labs (15)

Publicité

01 ElasticSearch : Getting Started

  1. 1. ElasticSearch Getting Started http://elastic.openthinklabs.com/
  2. 2. Uji Coba Instalasi ● curl 'http://localhost:9200/?pretty' ● http://localhost:9200/_plugin/marvel/ ● http://localhost:9200/_plugin/marvel/sense/
  3. 3. Talking to Elasticsearch ● Java API ● RESTful API with JSON over HTTP curl -X<VERB> '<PROTOCOL>://<HOST>/<PATH>?<QUERY_STRING>' -d '<BODY>' curl -XGET 'http://localhost:9200/_count?pretty' -d ' { "query": { "match_all": {} } } '
  4. 4. Document Oriented
  5. 5. JSON
  6. 6. Finding Your Feet
  7. 7. Let's Build an Employee Directory ● Enable data to contain multi value tags, numbers, and full text. ● Retrieve the full details of any employee ● Allow structured search, such as finding employees over the age of 30 ● Allow simple full-text search and more-complex phrase searches ● Return highlighted search snippets from the text in the matching documents ● Enable management to build analytic dashboards over the data
  8. 8. Indexing Employee Documents ● Relational DB Databases Tables Rows⇒ ⇒ ⇒ Columns⇒ ● Elasticsearch Indices Types Documents⇒ ⇒ ⇒ Fields⇒
  9. 9. Index Versus Index Versus Index ● Index (noun) ● Index (verb) ● Inverted index
  10. 10. Indexing Employee Documents ● Megacorp : The index name ● Employee : The type name ● 1 : The ID of this particular employee PUT /megacorp/employee/1 { "first_name" : "John", "last_name" : "Smith", "age" : 25, "about" : "I love to go rock climbing", "interests": [ "sports", "music" ] } PUT /megacorp/employee/2 { "first_name" : "Jane", "last_name" : "Smith", "age" : 32, "about" : "I like to collect rock albums", "interests": [ "music" ] } PUT /megacorp/employee/3 { "first_name" : "Douglas", "last_name" : "Fir", "age" : 35, "about" : "I like to build cabinets", "interests": [ "forestry" ] }
  11. 11. Retrieving a Document ● GET /megacorp/employee/1 { "_index": "megacorp", "_type": "employee", "_id": "1", "_version": 2, "found": true, "_source": { "first_name": "John", "last_name": "Smith", "age": 25, "about": "I love to go rock climbing", "interests": [ "sports", "music" ] } }
  12. 12. Search Lite ● GET /megacorp/employee/_search ● GET /megacorp/employee/_search?q=last_name:Smith
  13. 13. Search with Query DSL GET /megacorp/employee/_search { "query" : { "match" : { "last_name" : "Smith" } } }
  14. 14. More-Complicated Searches GET /megacorp/employee/_search { "query" : { "filtered" : { "filter" : { "range" : { "age" : { "gt" : 30 } } }, "query" : { "match" : { "last_name" : "smith" } } } } }
  15. 15. Full-Text Search GET /megacorp/employee/_search { "query" : { "match" : { "about" : "rock climbing" } } }
  16. 16. Phrase Search GET /megacorp/employee/_search { "query" : { "match_phrase" : { "about" : "rock climbing" } } }
  17. 17. Highlighting Our Searches GET /megacorp/employee/_search { "query" : { "match_phrase" : { "about" : "rock climbing" } }, "highlight": { "fields": { "about":{} } } }
  18. 18. Analytics GET /megacorp/employee/_search { "aggs": { "all_interests": { "terms": { "field": "interests" } } } } GET /megacorp/employee/_search { "query": { "match": { "last_name": "smith" } }, "aggs": { "all_interests": { "terms": { "field": "interests" } } } } GET /megacorp/employee/_search { "aggs" : { "all_interests" : { "terms" : { "field" : "interests" }, "aggs" : { "avg_age" : { "avg" : { "field" : "age" } } } } } }
  19. 19. Referensi ● ElasticSearch, The Definitive Guide, A Distributed Real-Time Search and Analytics Engine, Clinton Gormely & Zachary Tong, O’Reilly

×