Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.

DRUPAL AND ELASTICSEARCH

15 vues

Publié le

Presentation of the Elasticsearch and Drupal integration - the Elasticsearch Connector module and other magic.

https://drupalcampkyiv.org/node/68

Publié dans : Formation
  • Soyez le premier à commenter

  • Soyez le premier à aimer ceci

DRUPAL AND ELASTICSEARCH

  1. 1. Drupal And ElasticsearchAlex Goja
  2. 2. Flexible and powerful open source, distributed real-time search and analytics engine for the cloud Elasticsearch
  3. 3. Flexible and powerful open source, distributed real-time search and analytics engine for the cloud Elasticsearch RESTful API on top of Lucene library
  4. 4. Why use Elasticsearch?
  5. 5. Why use Elasticsearch? ● RESTful API 
 ● Open Source 
 ● JSON over HTTP 
 ● based on Lucene 
 ● distributed 
 ● highly available 
 ● schema free 
 ● massively scalable 

  6. 6. How to use it?
  7. 7. How to use it? > curl -XGET localhost:9200/?pretty
  8. 8. How to use it? > 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" }
  9. 9. How to use it? > curl -XGET localhost:9200/?pretty action
  10. 10. How to use it? > curl -XGET localhost:9200/?pretty node + port
  11. 11. How to use it? > curl -XGET localhost:9200/?pretty path
  12. 12. How to use it? > curl -XGET localhost:9200/?pretty query string
  13. 13. Let's index some data
  14. 14. Let's index some data > PUT /index/type/id Where? It's very similar to database in SQL
  15. 15. Let's index some data > PUT /index/type/id What? Table
 Content type,
 Entity type,
 any kind of type you decide
  16. 16. Let's index some data > PUT /index/type/id Which? Node ID, Entity ID,
 any kind of serial ID
  17. 17. Let's index some data > PUT /mysite/node/1 {
 "nid": "1", "status": "1",
 "title": "Hello elasticsearch",
 "body": "First elasticsearch document" }
  18. 18. Let's index some data > 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 }
  19. 19. Let's GET some data
  20. 20. Let's GET some data > 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" } }
  21. 21. Let's GET some data Get specific fields > GET /mysite/node/1?fields=title,body Get source only > GET /mysite/node/1/_source
  22. 22. Let's UPDATE some data > PUT /mysite/node/1 { “status":"0" }
  23. 23. Let's UPDATE some data > PUT /mysite/node/1 { "status":"0" } {
 "ok":true, "_index":"mysite", "_type":"node", "_id":"1", "_version":2 }
  24. 24. Let's DELETE some data
  25. 25. Let's DELETE some data > DELETE /mysite/node/1
  26. 26. Let's DELETE some data > DELETE /mysite/node/1 { "ok":true, "found":true, "_index":"mysite", "_type":"node", "_id":"1", “_version":3 }
  27. 27. Let's SEARCH for something
  28. 28. Let's SEARCH for something > GET /_search { "took" : 32, "timed_out" : false, "_shards" : { "total" : 20, "successful" : 20, "failed" : 0 }, "hits" : { results... } }
  29. 29. Let's SEARCH in multiple indices and types
  30. 30. Let's SEARCH in multiple indices and types > GET /index/_search > GET /index1,index2/_search > GET /index/type/_search 
 > GET /myapp_*/type, entity_*/_search
  31. 31. Let's PAGINATE results
  32. 32. Let's PAGINATE results > GET /_search?size=10&from=20 size = results per page from = starting from
  33. 33. Let's search oldschool
  34. 34. Let's search oldschool > GET /_search?q=title:elasticsearch > GET /_search?q=nid:60
  35. 35. Query DSL style
  36. 36. Query DSL style > GET /_search?size=10&from=20 { "query": {
 “match": "awesome" } }
  37. 37. Query DSL style > GET /_search?size=10&from=20 {
 "query": { "field" : { "title" : { “query" : "+awesome -poor", "boost" : 2.0, } } } }
  38. 38. Queries & Filters
  39. 39. Queries & Filters full text search exact match relevance score show or hide heavy lightning fast
 not cacheable cacheable
  40. 40. Combine Filters & Queries
  41. 41. Combine Filters & Queries {
 "query": { "filtered": { "query": { "match": { "title": "awesome" } }, "filter": {
 "term": { "type": "article" } } } } } > GET /_search
  42. 42. Sorting
  43. 43. Sorting {
 "query": { "filtered": { "query": { “match": { "title": "awesome" } }, "filter": {
 "term": { "type": "article" } } } } "sort": {"date":"desc"} } > GET /_search
  44. 44. and Facets "aggregations" : { "<aggregation_name>" : { "<aggregation_type>" : { <aggregation_body> } [,"meta" : { [<meta_data_body>] } ]? [,"aggregations" : { [<sub_aggregation>]+ } ]? } [,"<aggregation_name_2>" : { ... } ]* }
  45. 45. and Facets > GET /_search { "aggregations": { "home_team": { "terms": {
 "field": “field_home_team" } } } }
  46. 46. and Facets > GET /_search { "aggregations": { "home_team": { "terms": {
 "field": “field_home_team" } } } } Give your facet a name
  47. 47. and Facets > GET /_search { "aggregations": { "home_team": { "terms": {
 "field": “field_home_team" } } } } Your facet filter can be: ● Terms
 ● Range
 ● Histogram
 ● Date Histogram ● Filter
 ● Query
 ● Statistical
 ● Terms Stats
 ● Geo Distance
 ● Cardinality
 ● Nested
  48. 48. and Facets "aggregations" : { "home_team" : { "_type" : "terms", "missing" : 203, "total" : 100, "other" : 42, "terms" : [ { "term" : "hou", "count" : 8 }, {
 "term" : "sln", "count" : 6 }, ...
  49. 49. STOP! I want this in Drupal
  50. 50. STOP! I want this in Drupal Available modules: Search API + elasticsearch_connector
  51. 51. Let the Search be with you

×