Upgrade to Pro — share decks privately, control downloads, hide ads and more …

What's New in Percolator

Luca Cavanna
October 02, 2013
15k

What's New in Percolator

Presentation given at the BeLux elasticsearch meetup on October 2nd 2013 in Brussels

Luca Cavanna

October 02, 2013
Tweet

Transcript

  1. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited What’s New in Percolator? @lucacavanna Elasticsearch User Group BeLux
  2. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited Agenda What is the percolator? What do people use it for? How does it work? Why did it need a redesign? What was changed exactly?
  3. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited Agenda What is the percolator? What do people use it for? How does it work? Why did it need a redesign? What was changed exactly?
  4. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited Agenda What is the percolator? What do people use it for? How does it work? Why did it need a redesign? What was changed exactly?
  5. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited Agenda What is the percolator? What do people use it for? How does it work? Why did it need a redesign? What was changed exactly?
  6. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited Agenda What is the percolator? What do people use it for? How does it work? Why did it need a redesign? What has changed?
  7. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited PUT /twitter/tweet/1 -d ' { "tweet": "#elasticsearch is AWESOME", "nick": "@lucacavanna", "name": "Luca Cavanna", "date": "2013-10-02", "rt": 5, "loc": { ! "lat": 13.4, ! "lon": 52.5 } } ' We are used to docs...
  8. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited ...and queries GET /_search -d ' { "query": { "match": { "tweet": "elasticsearch" } } } '
  9. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited PUT /_percolator/twitter/es-tweets Let’s index a query... verb (index request)
  10. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited PUT /_percolator/twitter/es-tweets Let’s index a query... reserved index
  11. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited PUT /_percolator/twitter/es-tweets Let’s index a query... index to register query against
  12. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited PUT /_percolator/twitter/es-tweets Let’s index a query... query identifier
  13. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited Let’s index a query... PUT /_percolator/twitter/es-tweets -d ' { "query": { "match": { "tweet": "elasticsearch" } } } ' the query
  14. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited GET /twitter/tweet/_percolate ...and percolate a doc verb (percolate request)
  15. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited GET /twitter/tweet/_percolate ...and percolate a doc index to percolate against (needs to exist although empty)
  16. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited GET /twitter/tweet/_percolate ...and percolate a doc percolate api endpoint
  17. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited GET /twitter/tweet/_percolate -d ' { “doc”: { "tweet": "#elasticsearch is AWESOME", "nick": "@lucacavanna", "name": "Luca Cavanna", "date": "2013-10-02", "rt": 5, "loc": { ! "lat": 13.4, ! "lon": 52.5 } } } ' ...and percolate a doc document
  18. { "ok": "true", "matches": ["es-tweets"] } Copyright Elasticsearch 2013. Copying,

    publishing and/or distributing without written permission is strictly prohibited ...and percolate a doc # 200 OK matching queries
  19. { "ok": "true", "matches": ["es-tweets"] } Copyright Elasticsearch 2013. Copying,

    publishing and/or distributing without written permission is strictly prohibited ...and percolate a doc # 200 OK PUT /_percolator/twitter/es-tweets -d ' { "query": { "match": { "tweet": "elasticsearch" } } } '
  20. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited weather forecast alerts PUT /_percolator/forecast/summer -d ' { "query": { “range”: { “max” : { “gte” : 30 } } } } '
  21. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited weather forecast alerts GET /forecast/type/_percolate -d ' { “doc” : { "date": "2013-07-25", "wind": 1, "min": "22", "max": "32", "rain": 0 } } '
  22. { "ok": "true", "matches": ["summer"] } Copyright Elasticsearch 2013. Copying,

    publishing and/or distributing without written permission is strictly prohibited # 200 OK weather forecast alerts
  23. { "ok": "true", "matches": ["summer"] } Copyright Elasticsearch 2013. Copying,

    publishing and/or distributing without written permission is strictly prohibited # 200 OK the summer is coming! weather forecast alerts
  24. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited Alerting applies also to: Price monitoring News alerts Stock alerts Logs monitoring
  25. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited Alerting applies also to: Price monitoring News alerts Stock alerts Logs monitoring
  26. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited Alerting applies also to: Price monitoring News alerts Stock alerts Logs monitoring
  27. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited Alerting applies also to: Price monitoring News alerts Stock alerts Logs monitoring
  28. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited Alerting applies also to: Price monitoring News alerts Stock alerts Logs monitoring ...and many more
  29. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited Store users queries PUT /_percolator/ads/user1 -d ' { "query": { “match”: { “text” : “iphone subscription”, “operator” : “and” } } } '
  30. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited Let’s percolate the ad... GET /ads/apple/_percolate -d ' { “doc” : { "text": "iPhone from 1 euro", "url": “http://www.myads.com/myads” } } '
  31. { "ok": "true", "matches": [] } Copyright Elasticsearch 2013. Copying,

    publishing and/or distributing without written permission is strictly prohibited # 200 OK No query matches ...and get feedback back
  32. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited Let’s modify the ad... GET /ads/apple/_percolate -d ' { “doc” : { "text": “iPhone subscription from 1 euro", "url": “http://www.myads.com/myads” } } '
  33. { "ok": "true", "matches": ["user1"] } Copyright Elasticsearch 2013. Copying,

    publishing and/or distributing without written permission is strictly prohibited # 200 OK How many people would the updated ad reach? ...and get feedback back
  34. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited Store articles patterns PUT /_percolator/article/apple -d ' { "query": { “multi_match”: { “fields” : [“title”,”content”], “query” : “ios apple iphone ipad” } } } '
  35. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited percolate a new article GET /article/tech/_percolate -d ' { “doc” : { "title": "iOS 7 released", "content": “iOS 7, the seventh major iteration of the mobile platform, includes more than 200 new features, including a brand new bright and colorful user interface.” } } '
  36. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited percolate a new article { "ok": "true", "matches": ["apple"] } GET /article/tech/_percolate -d ' { “doc” : { "title": "iOS 7 released", "content": “iOS 7, the seventh major iteration of the mobile platform, includes more than 200 new features, including a brand new bright and colorful user interface.” } } '
  37. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited index the enriched article PUT /article/tech/1 -d ' { "title": "iOS 7 released", "content": “iOS 7, the seventh major iteration of the mobile platform, includes more than 200 new features, including a brand new bright and colorful user interface.”, “tag” : “apple” } '
  38. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited GET /_percolator/_mapping special mapping
  39. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited GET /_percolator/_mapping { "_default_" : { "properties" : { "query" : { "type" : "object", "enabled" : false } } } } special mapping
  40. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited GET /_percolator/_mapping { "_default_" : { "properties" : { "query" : { "type" : "object", "enabled" : false } } } } special mapping queries are only stored
  41. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited How does it work? All queries are loaded in memory Each doc is indexed in memory All queries get executed against it Execution time linear (# of queries) The memory index gets cleaned up
  42. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited How does it work? All queries are loaded in memory Each doc is indexed in memory All queries get executed against it Execution time linear (# of queries) The memory index gets cleaned up
  43. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited How does it work? All queries are loaded in memory Each doc is indexed in memory All queries get executed against it Execution time linear (# of queries) The memory index gets cleaned up
  44. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited How does it work? All queries are loaded in memory Each doc is indexed in memory All queries get executed against it Execution time linear to # of queries The memory index gets cleaned up
  45. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited How does it work? All queries are loaded in memory Each doc is indexed in memory All queries get executed against it Execution time linear to # of queries The memory index gets cleaned up
  46. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited Query metadata PUT /_percolator/twitter/es-tweets -d ' { "query": { "match": { "tweet": "elasticsearch" } } } '
  47. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited Query metadata PUT /_percolator/twitter/es-tweets -d ' { "query": { "match": { "tweet": "elasticsearch" } }, “user_id”: “lucacavanna” } '
  48. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited Query metadata PUT /_percolator/twitter/es-tweets -d ' { "query": { "match": { "tweet": "elasticsearch" } }, “user”: { “name” : “Luca Cavanna”, “nick” : “lucacavanna” } } '
  49. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited Retrieve query by id GET /_percolator/twitter/es-tweets
  50. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited GET /_percolator/twitter/es-tweets { "query": { "match": { "tweet": "elasticsearch" } }, “user”: { “name” : “Luca Cavanna”, “nick” : “lucacavanna” } } Retrieve query by id
  51. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited GET /twitter/tweet/_percolate -d ' { “doc” : { "tweet": "#elasticsearch is AWESOME", "nick": "@lucacavanna" }, “query” : { “term” : {“user.nick” : “lucacavanna”} } } ' Drill down
  52. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited GET /twitter/tweet/_percolate -d ' { “doc” : { "tweet": "#elasticsearch is AWESOME", "nick": "@lucacavanna" }, “query” : { “term” : {“user.nick” : “lucacavanna”} } } ' Drill down restricts the # of queries to run
  53. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited GET /_percolator/_settings special settings
  54. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited GET /_percolator/_settings { "_percolator" : { "settings" : { "index.version.created" : "900599", "index.number_of_replicas" : "0", "index.number_of_shards" : "1", "index.auto_expand_replicas" : "0-all" } } } special settings
  55. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited Node 1 _percolator 0P Node 2 _percolator 0R
  56. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited Node 1 _percolator 0P Node 2 _percolator 0R Node 3 _percolator 0R
  57. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited Let’s index a query... PUT /_percolator/twitter/es-tweets -d ' { "query": { "match": { "tweet": "elasticsearch" } } } '
  58. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited Let’s index a query... PUT /anyindex/twitter/es-tweets -d ' { "query": { "match": { "tweet": "elasticsearch" } } } ' any index can contain queries to percolate against
  59. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited Let’s index a query... PUT /anyindex/_percolator/es-tweets -d ' { "query": { "match": { "tweet": "elasticsearch" } } } ' reserved type for queries to percolate against
  60. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited GET /index1,index2/tweet/_percolate -d ' { “doc”: { "tweet": "#elasticsearch is AWESOME", "nick": "@lucacavanna", "name": "Luca Cavanna", "date": "2013-10-02", "rt": 5, "loc": { ! "lat": 13.4, ! "lon": 52.5 } } } ' Multi-index support
  61. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited GET /alias1/tweet/_percolate -d ' { “doc”: { "tweet": "#elasticsearch is AWESOME", "nick": "@lucacavanna", "name": "Luca Cavanna", "date": "2013-10-02", "rt": 5, "loc": { ! "lat": 13.4, ! "lon": 52.5 } } } ' Full alias support
  62. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited Routing support PUT /anyindex/_percolator/id?routing=user1 -d ' { "query": { "match": { "tweet": "elasticsearch" } } } '
  63. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited GET /twitter/tweet/_percolate?routing=user1 -d ' { “doc”: { "tweet": "#elasticsearch is AWESOME", "nick": "@lucacavanna", "name": "Luca Cavanna", "date": "2013-10-02", "rt": 5, "loc": { ! "lat": 13.4, ! "lon": 52.5 } } } Routing support
  64. { "took": 9, “_shards” : { “total” : 5, “successful”

    : 5, “failed” : 0 }, “count” : 1, "matches": [ { “_index” : “index1”, “_id” : “es-tweets” } ] } Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly prohibited New percolate response
  65. { "took": 9, “_shards” : { “total” : 5, “successful”

    : 5, “failed” : 0 }, “count” : 1, "matches": [ { “_index” : “index1”, “_id” : “es-tweets” } ] } Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly prohibited New percolate response
  66. { "took": 9, “_shards” : { “total” : 5, “successful”

    : 5, “failed” : 0 }, “count” : 1, "matches": [ { “_index” : “index1”, “_id” : “es-tweets” } ] } Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly prohibited New percolate response
  67. { "took": 9, “_shards” : { “total” : 5, “successful”

    : 5, “failed” : 0 }, “count” : 1, "matches": [ { “_index” : “index1”, “_id” : “es-tweets” } ] } Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly prohibited New percolate response
  68. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited GET /twitter/tweet/1/_percolate Percolate existing doc
  69. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited GET /twitter/tweet/1/_percolate Percolate existing doc 1) index that contains the document
  70. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited GET /twitter/tweet/1/_percolate Percolate existing doc 1) index that contains the document 2) and the queries (_percolator type)
  71. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited GET /twitter/tweet/1/_percolate Percolate existing doc type & id of the existing doc
  72. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited GET /twitter/tweet/1/_percolate? percolate_index=my-percolator Percolate existing doc separate index where the queries are
  73. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited GET /twitter/tweet/_percolate/count -d ' { “doc”: { "tweet": "#elasticsearch is AWESOME", "nick": "@lucacavanna", "name": "Luca Cavanna", "date": "2013-10-02", "rt": 5, "loc": { ! "lat": 13.4, ! "lon": 52.5 } } } ' Percolate count api
  74. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited Percolate count api { "took": 9, “_shards” : { “total” : 5, “successful” : 5, “failed” : 0 }, “count” : 1 }
  75. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited GET /twitter/tweet/_percolate -d ' { “doc” : { "tweet": "#elasticsearch is AWESOME", "nick": "@lucacavanna" }, “filter” : { “term” : {“user.nick” : “lucacavanna”} } } ' Support for filters
  76. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited Highlighting PUT /twitter/_percolator/1 -d ' { "query": { "match": { "tweet": "elasticsearch" } } } '
  77. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited Highlighting PUT /twitter/_percolator/1 -d ' { "query": { "match": { "tweet": "elasticsearch" } } } ' PUT /twitter/_percolator/2 -d ' { "query": { "match": { "tweet": "awesome" } } } '
  78. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited GET /twitter/tweet/_percolate -d ' { “doc”: { "tweet": "#elasticsearch is AWESOME" }, “highlight”: { “fields” : { “tweet”:{} } }, “size” : 5 } ' Highlighting
  79. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited { ......... “matches”: [ { “_index” : “twitter”, “_id” : “1”, "tweet": "#<em>elasticsearch</em> is AWESOME" }, { “_index” : “twitter”, “_id” : “2”, "tweet": "#elasticsearch is <em>AWESOME</em>" } ] } ' Highlighting
  80. PUT /_percolator/twitter/es-tweets -d ' { "query": { "match": { "tweet":

    "elasticsearch" } }, “user”: { “name” : “Luca Cavanna”, “nick” : “lucacavanna” } } ' Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly prohibited Basic scoring
  81. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited Basic scoring PUT /_percolator/twitter/es-tweets -d ' { "query": { "match": { "tweet": "elasticsearch" } }, “user”: { “name” : “Luca Cavanna”, “nick” : “lucacavanna” } } ' GET /twitter/tweet/_percolate -d ' { “doc” : { "tweet": "#elasticsearch is AWESOME", "nick": "@lucacavanna" }, “query” : { “match” : {“user.name” : “Luca”} } } '
  82. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited Basic scoring PUT /_percolator/twitter/es-tweets -d ' { "query": { "match": { "tweet": "elasticsearch" } }, “user”: { “name” : “Luca Cavanna”, “nick” : “lucacavanna” } } ' GET /twitter/tweet/_percolate -d ' { “doc” : { "tweet": "#elasticsearch is AWESOME", "nick": "@lucacavanna" }, “query” : { “match” : {“user.name” : “Luca”} } } ' How well does it match?
  83. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited Sorting Sort by score Only return the score Limit number of results Further improvements
  84. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited Sorting Sort by score Only return the score Limit number of results Further improvements
  85. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited Sorting Sort by score Only return the score Limit number of matches Further improvements
  86. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited Sorting Sort by score Only return the score Limit number of matches Boosting based on metadata
  87. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited Sorting Sort by score Only return the score Limit number of matches Boosting based on metadata Further improvements
  88. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission

    is strictly prohibited Multi percolate GET /_mpercolate {“percolate” : {“index”:”twitter”, “type”:”tweet”} } {“doc”: {“text”:“elasticsearch is AWESOME!”} } {“percolate” : {“index”:”twitter”, “type”:”tweet”, “id”:”id1”} } {} {“count” : {“index”:”twitter”, “type”:”tweet”} } {“doc”: {“text”:“elasticsearch rocks!”} } {“count” : {“index”:”twitter”, “type”:”tweet”, “id”:”id2”} } {}