Elasticsearch

  • 847 views
Uploaded on

 

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
847
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
30
Comments
0
Likes
3

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Why so serious?
  • 2.  Cloud friendly database Based on Apache Lucene (Java) Linux only
  • 3.  Document oriented Schema free – why bother? REST API JSON
  • 4. _________{ "book": { "name": "PHP a XML", "ean": 9788024711164, "producer": "Grada", "price": 249, "author": { "name": "Jiří", "lastname": "Kosek" }, "categories": [ "XML", "PHP" ] }}
  • 5. $ curl –XPUT localhost:9200/amazon/book/978802471164 –d‘{ "book": { "name": "PHP a XML", "ean": 9788024711164, "producer": "Grada", "price": 249, "author": { "name": "Jiří", "lastname": "Kosek" }, "categories": [ "XML", "PHP" ] }}‘
  • 6. $ curl –XPUT localhost:9200/amazon/book/978802471164 –d‘{ "book": { "name": "PHP a XML", "ean": 9788024711164, "producer": "Grada", "price": 249, "author": { "name": "Jiří", "lastname": "Kosek" }, "categories": [ "XML", "PHP" ] }}‘
  • 7. $ curl –XPUT localhost:9200/amazon/book/978802471164 –d‘{ "book": { "name": "PHP a XML", "ean": 9788024711164, "producer": "Grada", "price": 249, "author": { "name": "Jiří", "lastname": "Kosek" }, "categories": [ "XML", "PHP" ] }}‘
  • 8. $ curl –XPUT localhost:9200/amazon/book/978802471164 –d‘{ "book": { "name": "PHP a XML", "ean": 9788024711164, "producer": "Grada", "price": 249, "author": { "name": "Jiří", "lastname": "Kosek" }, "categories": [ "XML", "PHP" ] }}‘
  • 9. $ curl –XGETlocalhost:9200/amazon/book/9788024711164
  • 10. $ curl –XGETlocalhost:9200/amazon/book/_search?q=category:XML
  • 11. $ curl –XGETlocalhost:9200/amazon/book/_search?q=category:XML&from=10&size=10
  • 12. $ curl –XGETlocalhost:9200/amazon/book,page/_search?q=category:XML
  • 13. $ curl –XGETlocalhost:9200/amazon/_search?q=category:XML
  • 14. { "took": 3, "timed_out": false, "_shards": { "total": 1, "successful": 1, "failed": 0 }, "hits": { "total": 119, "max_score": 0.23119758, "hits": [ { "_index": "levneucebnice_fulltext4", "_type": "products", "_id": "64135", "_score": 0.23119758, "_source": { "id": "64135", "name": "Anatomie 1 - Třetí, upravené a doplněnévydání",
  • 15.  Specific searching Multiple conditions
  • 16. { "match" : { "book.name" : "PHP a XML" }}WHERE name = "PHP a XML"
  • 17. { "ids" : { "type" : "book", "values" : [ 9788024711164, 9788024727257 ] }}WHERE id IN(...)
  • 18. { "prefix" : { "producer" : "gra" }}WHERE producer LIKE "gra%"
  • 19. { "range": "price": { "from": 200, "to": 300 } }}WHERE price BETWEEN 200 AND 300
  • 20. + = single character* = mulitple characters{ "wildcard" : { "book.name" :"P+P *" }}
  • 21. { "span_first" : { "match" : { "span_term" : { "name" : "PHP" } }, "end" : 1 }}
  • 22.  Combining conditions No default order{ "bool" : { "must" : { "term" : { "producer" : "grada" } }, "must_not" : { "range" : { "price" : { "from" : 100, "to" : 200 } } }, "should" : [ { "term" : { "category" : "PHP" } }, { "term" : { "category" : "XML" } } ] }}
  • 23. { "query": { "bool": { "should": [ { "ids": { "values": [ "64135" ], "boost": 1000000 } }, { "ids": { "values": [ "60558" ], "boost": 999000 } },
  • 24.  Sometimes too easy Many ways to hit the target Sometimes too complicated Sometimes unpredicted behaviour Difficult debugging