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

TouchDB-Lucene: NoSQL on Android

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)

sameersegal

November 02, 2012
Tweet

More Decks by sameersegal

Other Decks in Technology

Transcript

  1. 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; }
  2. 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
  3. 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");
  4. 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();
  5. 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; } }
  6. 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" } } ]
  7. 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