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.

CouchDB Day NYC 2017: Mango

175 views

Published on

Mango allows users to declaratively define and query Apache CouchDB indexes. Mango leverages Lucene not only to perform text search, but also to enable ad-hoc querying capabilities.

Published in: Software
  • Be the first to comment

CouchDB Day NYC 2017: Mango

  1. 1. Lab: Mango (30 minutes) Bradley Holt, Developer Advocate Thursday, February 9, 2017 CouchDB Developer Day @BradleyHolt
  2. 2. Prerequisite: Replication Lab @BradleyHolt
  3. 3. Mango  Declarative indexes  MongoDB-style query language  You can still use map/reduce views @BradleyHolt
  4. 4. http-console $ npm install http-console -g @BradleyHolthttps://github.com/cloudhead/http-console
  5. 5. http-console $ npm install http-console -g $ http-console 127.0.0.1:5984 @BradleyHolthttps://github.com/cloudhead/http-console
  6. 6. http-console $ npm install http-console -g $ http-console 127.0.0.1:5984 > http-console 0.6.3 > Welcome, enter .help if you're lost. > Connecting to 127.0.0.1 on port 5984. @BradleyHolthttps://github.com/cloudhead/http-console
  7. 7. Connecting to CouchDB 2.0 $ http-console root:passw0rd@127.0.0.1:5984 --json @BradleyHolt
  8. 8. Connecting to CouchDB 2.0 $ http-console root:passw0rd@127.0.0.1:5984 --json > http-console 0.6.3 > Welcome, enter .help if you're lost. > Connecting to 127.0.0.1 on port 5984. @BradleyHolt
  9. 9. Connecting to IBM Cloudant $ http-console https://bradley-holt:passw0rd@bradley-holt.cloudant.com --json @BradleyHolt
  10. 10. Connecting to IBM Cloudant $ http-console https://bradley-holt:passw0rd@bradley-holt.cloudant.com --json > http-console 0.6.3 > Welcome, enter .help if you're lost. > Connecting to bradley-holt.cloudant.com on port 443. @BradleyHolt
  11. 11. Mango /> @BradleyHolt
  12. 12. Mango /> /kittens @BradleyHolt
  13. 13. Mango /kittens> @BradleyHolt
  14. 14. Mango /kittens> POST /_index @BradleyHolt
  15. 15. Mango /kittens> POST /_index ... @BradleyHolt
  16. 16. Mango /kittens> POST /_index ... { "index": { "fields": [ "age_weeks", "weight_kilograms" ] } } @BradleyHolt
  17. 17. Mango /kittens> POST /_index ... { "index": { "fields": [ "age_weeks", "weight_kilograms" ] } } HTTP/1.1 200 OK Content-Type: application/json { result: 'created', id: '_design/e19dde7f518129a966ebe072edc66be88d54e694', name: 'e19dde7f518129a966ebe072edc66be88d54e694' } @BradleyHolt
  18. 18. @BradleyHolt
  19. 19. Mango /kittens> @BradleyHolt
  20. 20. Mango /kittens> POST /_find @BradleyHolt
  21. 21. Mango /kittens> POST /_find ... @BradleyHolt
  22. 22. Mango /kittens> POST /_find ... { "selector": { "age_weeks": { "$gte": 7, "$lte": 10 } }, "fields": [ "_id", "age_weeks" ] } @BradleyHolt
  23. 23. Mango /kittens> POST /_find ... { "selector": { "age_weeks": { "$gte": 7, "$lte": 10 } }, "fields": [ "_id", "age_weeks" ] } HTTP/1.1 200 OK Content-Type: application/json { docs: [ { _id: 'tiger', age_weeks: 7 }, { _id: 'daisy', age_weeks: 9 }, { _id: 'mittens', age_weeks: 10 } ] } @BradleyHolt
  24. 24. @BradleyHolt
  25. 25. Mango /kittens> @BradleyHolt
  26. 26. Mango /kittens> POST /_find @BradleyHolt
  27. 27. Mango /kittens> POST /_find ... @BradleyHolt
  28. 28. Mango /kittens> POST /_find ... { "selector": { "age_weeks": { "$gte": 0 }, "weight_kilograms": { "$gte": 0.5, "$lte": 1 } }, "fields": [ "_id", "weight_kilograms" ] } @BradleyHolt
  29. 29. Mango /kittens> POST /_find ... { "selector": { "age_weeks": { "$gte": 0 }, "weight_kilograms": { "$gte": 0.5, "$lte": 1 } }, "fields": [ "_id", "weight_kilograms" ] } HTTP/1.1 200 OK Content-Type: application/json { docs: [ { _id: 'tiger', weight_kilograms: 0.726 }, { _id: 'daisy', weight_kilograms: 0.816 }, { _id: 'mittens', weight_kilograms: 0.997 } ] } @BradleyHolt
  30. 30. @BradleyHolt
  31. 31. Try It On Your Own 1. Create an index of kittens by weight_kilograms and age_weeks (in that order) 2. Find kittens weighing less than 1 kilogram who are 7 weeks or older @BradleyHolt
  32. 32. Image Credit  Mango with section on a white background by bangdoll, on Flickr <https://flic.kr/p/9CBP2h> @BradleyHolt
  33. 33. Lab: Mango CouchDB Developer Day @BradleyHolt

×