Real-time search in Drupal. Meet Elasticsearch

7,416 views
7,138 views

Published on

Published in: Technology
3 Comments
6 Likes
Statistics
Notes
  • @asgorobets Спасибо, и за доклад и за ответ!
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Это модуль Migrate, в нем есть migrate_baseball_example, это фича с контент тайпом, плюс при инсталяции модуля она подтягивает csv-шки матчей которые в последствии можно смигрировать.

    Единственное замечание, файлы .csv были переименованы и в стабильной версии Migrate название файлов отлично от искомого, нужно либо ставить dev либо патчить. Вот ищу: https://drupal.org/node/2008200
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Внезапно!
    На докладе в Москве упоминались демо-данные то ли бейсбольных, то ли футбольных команд. Их можно где-то взять или это закрытые разработки? :)
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
7,416
On SlideShare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
55
Comments
3
Likes
6
Embeds 0
No embeds

No notes for slide

Real-time search in Drupal. Meet Elasticsearch

  1. 1. Real-time search in Drupal. Meet Elasticsearch By Alexei Gorobets asgorobets
  2. 2. Elasticsearch Flexible and powerful open source, distributed real-time search and analytics engine for the cloud
  3. 3. Elasticsearch Flexible and powerful open source, distributed real-time search and analytics engine for the cloud RESTful API on top of Lucene library
  4. 4. Why use Elasticsearch?
  5. 5. ● RESTful API ● Open Source ● JSON over HTTP ● based on Lucene ● distributed ● highly available ● schema free ● massively scalable
  6. 6. STOP! Why not SOLR?
  7. 7. ● Solr vs Elasticsearch: Features Smackdown ● Detailed overview ● Slideshare presentation by Sematext ● Realtime Search: Solr vs Elasticsearch Apache Solr vs Elasticsearch
  8. 8. Setup in 2 steps: 1. Extract the archive 2. > bin/elasticsearch
  9. 9. How to use it?
  10. 10. > curl -XGET localhost:9200/?pretty
  11. 11. > curl -XGET localhost:9200/?pretty { "ok" : true, "status" : 200, "name" : "Infinity", "version" : { "number" : "0.90.1", "snapshot_build" : false, "lucene_version" : "4.3" }, "tagline" : "You Know, for Search" }
  12. 12. > curl -XGET localhost:9200/?pretty action
  13. 13. > curl -XGET localhost:9200/?pretty node + port
  14. 14. > curl -XGET localhost:9200/?pretty path
  15. 15. > curl -XGET localhost:9200/?pretty query string
  16. 16. Let's index some data
  17. 17. > PUT /index/type/id Where? It's very similar to database in SQL
  18. 18. > PUT /index/type/id What? Table Content type, Entity type, any kind of type you decide
  19. 19. > PUT /index/type/id Which? Node ID, Entity ID, any kind of serial ID
  20. 20. > PUT /mysite/node/1 -d { "nid": "1", "status": "1", "title": "Hello elasticsearch", "body": "First elasticsearch document" }
  21. 21. > PUT /mysite/node/1 -d { "nid": "1", "status": "1", "title": "Hello elasticsearch", "body": "First elasticsearch document" } { "ok":true, "_index":"mysite", "_type":"node", "_id":"1", "_version":1 }
  22. 22. Let's GET some data
  23. 23. > GET /mysite/node/1 { "_index" : "mysite", "_type" : "node", "_id" : "1", "_version" : 1, "exists" : true, "_source" : { "nid":"1", "status":"1", "title":"Hello elasticsearch", "body":"First elasticsearch document" }
  24. 24. > GET /mysite/node/1?fields=title,body Get specific fields
  25. 25. > GET /mysite/node/1?fields=title,body Get specific fields > GET /mysite/node/1/_source Get source only
  26. 26. Let's UPDATE some data
  27. 27. > PUT /mysite/node/1 -d { "status":"0" }
  28. 28. > PUT /mysite/node/1 -d { "ok":true, "_index":"mysite", "_type":"node", "_id":"1", "_version":2 } { "status":"0" }
  29. 29. UPDATE = DELETE + PUT
  30. 30. Let's DELETE some data
  31. 31. > DELETE /mysite/node/1
  32. 32. > DELETE /mysite/node/1 { "ok":true, "found":true, "_index":"mysite", "_type":"node", "_id":"1", "_version":3 }
  33. 33. Let's SEARCH for something
  34. 34. > GET /_search
  35. 35. > GET /_search { "took" : 32, "timed_out" : false, "_shards" : { "total" : 20, "successful" : 20, "failed" : 0 }, "hits" : { results... } }
  36. 36. Let's SEARCH in multiple indices and types
  37. 37. > GET /index/_search > GET /index/type/_search > GET /index1,index2/_search > GET /myapp_*/type, entity_*/_search
  38. 38. Let's PAGINATE results
  39. 39. > GET /_search?size=10&from=20 size = results per page from = starting from
  40. 40. Let's search oldschool
  41. 41. > GET /_search?q=title:elasticsearch > GET /_search?q=nid:60
  42. 42. +title:awesome +status:1 +created:>1369917354
  43. 43. ?q=title:awesome%20%2Bcreated: >1369917354%20%2Bstatus:1 +title:awesome +status:1 +created:>1369917354 The ugly encoding =)
  44. 44. Query DSL style
  45. 45. > GET /_search -d { "query": { "match": "awesome" } }
  46. 46. > GET /_search -d { "query": { "field" : { "title" : { "query" : "+awesome -poor", "boost" : 2.0, } } } }
  47. 47. Queries & Filters
  48. 48. Queries & Filters full text search relevance score heavy not cacheable exact match show or hide lightning fast cacheable
  49. 49. Combine Filters & Queries
  50. 50. > GET /_search -d { "query": { "filtered": { "query": { "match": { "title": "awesome" } }, "filter": { "term": { "type": "article" } } } } }
  51. 51. and Sorting
  52. 52. > GET /_search -d { "query": { "filtered": { "query": { "match": { "title": "awesome" } }, "filter": { "term": { "type": "article" } } } } "sort": {"date":"desc"} }
  53. 53. and Facets
  54. 54. Facets on Amazon
  55. 55. > GET /_search -d { "facets": { "home_team": { "terms": { "field": "field_home_team" } } } }
  56. 56. > GET /_search -d { "facets": { "home_team": { "terms": { "field": "field_home_team" } } } } Give your facet a name
  57. 57. > GET /_search -d { "facets": { "home_team": { "terms": { "field": "field_home_team" } } } } Your facet filter can be: ● Terms ● Range ● Histogram ● Date Histogram ● Filter ● Query ● Statistical ● Terms Stats ● Geo Distance
  58. 58. "facets" : { "home_team" : { "_type" : "terms", "missing" : 203, "total" : 100, "other" : 42, "terms" : [ { "term" : "hou", "count" : 8 }, { "term" : "sln", "count" : 6 }, ...
  59. 59. STOP! I want this in Drupal?
  60. 60. Available modules: elasticsearch Search API elasticsearch
  61. 61. Development directions: 1. Search API implementation 2. Field Storage API Available modules: elasticsearch Search API elasticsearch
  62. 62. Field Storage API implementation Elasticsearch field storage sandbox by Damien Tournoud Started in July 2011
  63. 63. Field Storage API implementation Elasticsearch field storage sandbox by Damien Tournoud Started in July 2011 Elasticsearch EntityFieldQuery sandbox Commited today! =)
  64. 64. Let's DEMO
  65. 65. Elasticsearch sandbox here: https://drupal.org/sandbox/asgorobets/2073151
  66. 66. Let the Search be with you

×