Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Elasticsearch JVM-MX Meetup April 2016

762 views

Published on

Elasticsearch introduction at the Mexico City JVM Group.

Published in: Technology
  • Be the first to comment

Elasticsearch JVM-MX Meetup April 2016

  1. 1. Elasticsearch Mexico City JVM Group April 2016
  2. 2. !Gracias por estar aqui¡
  3. 3. ¡El meetup con mas asistencia de la historia!
  4. 4. What is the topic tonight?
  5. 5. Elastic search?
  6. 6. NO
  7. 7. Elastic Search?
  8. 8. NO
  9. 9. ElasticSearch?
  10. 10. NO
  11. 11. @superserch?
  12. 12. NO
  13. 13. Elasticsearch
  14. 14. YES
  15. 15. Search
  16. 16. Do I have to elaborate why search is important?
  17. 17. A little history…
  18. 18. Lucene History • Douglass Read "Doug" Cutting wrote Lucene in 1999 • Doug also is the author of Hadoop • In Lucene other projects came to life • Mahout • Tika • Nutch
  19. 19. Lucene?
  20. 20. • Lucene is an open-source Java full-text search library which makes it easy to add search functionality to an application or website.
  21. 21. Index
  22. 22. Query
  23. 23. Inverted index • Lucene creates a data structure where it keeps a list of where each word belongs.
  24. 24. Lucene-Based projects • Solr • Compass • Elasticsearch • Hibernate search
  25. 25. Elasticsearch You Know, for Search.
  26. 26. Features • Real-Time Data. I (Domingo) say near Real-Time Data. • Massively Distributed • High Availability • Full-Text Search • Document-Oriented • Schema-Free • Developer-Friendly, RESTful API • Extensible via plugins
  27. 27. Concepts • Cluster • Node • Index • Shard & Replica • Type • Mapping • Document
  28. 28. How data is organized in Elasticsearch
  29. 29. Nodes & shards
  30. 30. Indexing documents
  31. 31. Sharding is crucial • Shard is a physical Lucene index • # documents in a Lucent index is 2 billion docs. • When you create a index you have to declare the # shards, you can’t change later. Beware! • Don’t try to over-sharding your index! Beware!
  32. 32. Distributed indexing
  33. 33. URL http://localhost:9200/{index}/{type}/{document_id}
  34. 34. HTTPie for the samples
  35. 35. Creating an index $ http put :9200/my_index/ settings:='{ "index" : { "number_of_shards" : 3, "number_of_replicas" : 0 } }' PUT /my_index/ HTTP/1.1 Accept: application/json Accept-Encoding: gzip, deflate Connection: keep-alive Content-Length: 73 Content-Type: application/json Host: localhost:9200 User-Agent: HTTPie/0.9.3 { "settings": { "index": { "number_of_replicas": 0, "number_of_shards": 3 } } } HTTP/1.1 200 OK Content-Length: 21 Content-Type: application/json; charset=UTF-8 { "acknowledged": true }
  36. 36. Creating a type $ http put :9200/my_index/_mapping/my_document properties:='{ "user_name": { "type": "string" } }' -v PUT /my_index/_mapping/my_document1 HTTP/1.1 Accept: application/json Content-Length: 49 Content-Type: application/json { "properties": { "user_name": { "type": "string" } } } HTTP/1.1 200 OK Content-Length: 21 Content-Type: application/json; charset=UTF-8 { "acknowledged": true }
  37. 37. Indexing$ http :9200/my_index/my_document user_name="Domingo Suarez" -v POST /my_index/my_document1 HTTP/1.1 Content-Length: 31 Content-Type: application/json { "user_name": "Domingo Suarez” } HTTP/1.1 201 Created Content-Length: 149 Content-Type: application/json; charset=UTF-8 { "_id": "AVRaEeBK3Lbw2oDzSIWN", "_index": "my_index", "_shards": { "failed": 0, "successful": 1, "total": 1 }, "_type": "my_document1", "_version": 1, "created": true }
  38. 38. Search $ http :9200/my_index/my_document/_search?q=user_name:Domingo HTTP/1.1 200 OK Content-Length: 657 Content-Type: application/json; charset=UTF-8 { "_shards": { "failed": 0, "successful": 3, "total": 3 }, "hits": { "hits": [ { "_id": "AVRaEdPJ3Lbw2oDzSIWM", "_index": "my_index", "_score": 0.625, "_source": { "user_name": "Domingo Suarez" }, "_type": "my_document1" } ], "max_score": 0.625, "total": 1 }, "timed_out": false, "took": 5 }

×