Pro Yearly is on sale from $80 to $50! »

TouchDB-Lucene: NoSQL on Android

4a3cc45f2c6af14087c2e365341b1b02?s=47 sameersegal
November 02, 2012

TouchDB-Lucene: NoSQL on Android

The power of NoSQL (CouchDB) with advantage quick indexing (Lucene) on the world's biggest mobile platform (Android)

4a3cc45f2c6af14087c2e365341b1b02?s=128

sameersegal

November 02, 2012
Tweet

Transcript

  1. NoSQL on Android Sameer Segal http:/ /shinetechblog.files.wordpress.com/2011/11/android-on-couchdb.jpg?w=300&h=170 DroidCon - Bangalore

    | Nov 2nd, 2012
  2. Sameer Segal Artoo (http:/ /artoo.in) ICT4D Primary Healthcare Financial Inclusion

    Clean-Tech Full-stack Engineer: WebSockets
  3. App without Server http:/ /dorrys.com/wp-content/uploads/2009/11/fish_out_of_water.jpg ... fish out of water

  4. http:/ /theultralinx.com/wp-content/uploads/2012/03/android_hotspot-620x465.png Connectivity - Online / Offline Push notifications Conflict

    Resolution
  5. Time to Relax http:/ /4.bp.blogspot.com/-Y27tjnq3BLw/TxPvSHvtMPI/AAAAAAAAEkM/timXKQrA-ks/s1600/couchDB.png Document (JSON) Filtered Replication HTTP

    server
  6. Todo MVC (Backbone) => CouchApp

  7. Design Doc: Map / Reduce { _id: “_design/list_info”, map: function(doc)

    { if(doc.title) { emit(doc._id,doc); } }, / / Not using reduce reduce: function(key, values, rereduce) { return 1; }
  8. CouchDB on Android Couchbase Mobile Data on SDCard Service Couch

    API Seed Data ARM 7+ Initial load time high TouchDB Wrapper around SQLite Couch like API Light weight http:/ /www.wittistribune.com/wp-content/uploads/2011/08/couchbase_mobile_screenshot.png http:/ /labs.couchbase.com/TouchDB-iOS/logo/TouchDBLogo1000px.png
  9. CouchDB on Android couchbaselabs/TouchDB-Android

  10. Grocery Sync (Couchbase) => Android App couchbaselabs/AndroidGrocerySync/tree/touchdb

  11. Map / Reduce //install a view definition needed by the

    application TDDatabase db = server.getDatabaseNamed(DATABASE_NAME); TDView view = db.getViewNamed(String.format("%s/%s", dDocName, byOrderViewName)); view.setMapReduceBlocks(new TDViewMapBlock() { @Override public void map(Map<String, Object> document, TDViewMapEmitBlock emitter) { Object title = document.get("title"); if(title != null) { emitter.emit(document.get("_id").toString(), document); } } }, null, "1.0");
  12. Replication pushReplicationCommand = new ReplicationCommand.Builder() .source(DATABASE_NAME) .target(prefs.getString("sync_url", "http://couchy.artoo.in/ todo")) .continuous(true)

    .build(); pullReplicationCommand = new ReplicationCommand.Builder() .source(prefs.getString("sync_url", "http://couchy.artoo.in/ todo")) .target(DATABASE_NAME) .continuous(true) .build();
  13. Enter: http:/ /cdn.memegenerator.net/instances/400x/29437607 .jpg http:/ /windowsvj.com/wpblog/wp-content/uploads/2012/04/solr.jpg

  14. CouchDB-Lucene Luke - Lucene Index Toolbox rnewson/couchdb-lucene http:/ /fukamachi.github.com/images/github-icon.jpg index:

    function(doc) { if(doc.name) { var ret = new Document(); ret.add(doc.title, {'field':'title','store':'yes'}); ret.add(doc.completed, {'field':'completed',' store':'yes',' index':'not_analyzed'}); return ret; } else { return null; } }
  15. fetch_duration: 0, q: "title:d*", search_duration: 0, total_rows: 2, skip: 0,

    rows: [ { id: "a89f64228154c96206aaf71dcb227f84", score: 1, fields: { title: "Ensure demos are working correctly", completed: "false" } }, { id: "a89f64228154c96206aaf71dcb227c5c", score: 1, fields: { title: "Get to DroidCon on time", completed: "false" } } ]
  16. TouchDB-Android-Lucene ArtooTrills/TouchDB-Android-Lucene Activity Define IndexStrategy TouchDB 1 2 Specify Query

    Lucene 3 Change Listener HTTP API Indexes stored on file storage
  17. Location Queries

  18. Location Queries https:/ /developers.google.com/appengine/articles/img/sf_onetile.png

  19. Challenges TouchDB + TouchDB-Lucene = 7MB Share it between multiple

    apps through a service Rhino to the rescue TouchDB needs to reindex views every time it loads CouchDB Filters too slow Erlang improves performance by 30% (compared to JS) Seed the data using Lucene
  20. Q?! Sameer Segal Founder & CEO, Artoo www.artoo.in