Calling CouchDB Views from Couchbase lite

82 views
Skip to first unread message

Rajagopal V

unread,
Oct 7, 2016, 12:10:09 AM10/7/16
to Couchbase Mobile
We are running a CouchDB server from which documents are replicated(with a custom filter) through to Couchbase Lite Android and iOS. As the number of documents increases (we have databases that easily have more than 100000 records), the initial pull replication becomes slower and slower. I had written replication filters in javascript and converted them to erlang but both of them seem to be not very helpful and results in a lot of wait time before they are pulled (The erlang one seems slower which is strange as well). Thats a CouchDB issue anyway, and Ill post it there.

I was trying some other alternatives to do the initial pull. Some folks on SO suggested doing a view on CouchDB, getting the required documents and pulling them manually followed by a continuous _changes feed. This way, the views are very fast and you get the results faster to the mobile.

I remember an iOS branch couple years ago that allowed for a RemoteQuery from iOS but it doenst seem to have hit mainstream. What other options are available to execute a view from CouchDB in both CouchbaseLite Android/iOS? Should I just make a HTTP request to the Views and get it or is there a better way ?

Thanks for your help
Raja

Traun Leyden

unread,
Oct 11, 2016, 11:47:02 AM10/11/16
to mobile-c...@googlegroups.com
Couchbase Lite doesn't have any wrappers for accessing CouchDB views, so you'll have to do this on your own. 

You could either use a straight HTTP library like OkHttp, or a wrapper library like Ektorp

Also, Sync Gateway was built for this purpose, and has the concepts of channels + filtered replication.  If you can't use Sync Gateway for some reason, can you post the reasons why?  I'll make sure this gets back to the product manager.   (eg, do you have the requirement to use a managed database as opposed to self-hosting?)
 

--
You received this message because you are subscribed to the Google Groups "Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mobile-couchbase+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/b07b1ab9-3a17-41c6-a305-b3d36aa3b81c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Raja

unread,
Oct 12, 2016, 2:27:47 AM10/12/16
to mobile-c...@googlegroups.com
Thanks for the response. Our main reason for moving away from Sync Gateway at an earlier stage(about 2.5 years ago) was that we needed a way to create dynamic channels and they were becoming unmanageable. For e.g. we needed to synchronize Calendar Events with users and they would need them  based on a setting, i.e. user X needs events 3 days foreward and 2 days back, User Y needed 4 days foreward and 1 day back . This necessitated us to manage channels for every day of the year multiplied by the number of engineers. 

I will re-look at Sync Gateway now that we arent doing it as above with CouchDB. 

But I assume we cannot use Sync Gateway with CouchDB , so will have to figure a way to move our records from CouchDB to Couchbase Server and then use Sync Gateway if our current filtering seems unusable.

Thanks
Raja


--
You received this message because you are subscribed to a topic in the Google Groups "Couchbase Mobile" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mobile-couchbase/fqcvXtftNAY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mobile-couchbase+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/CACSSHCFWqdS%3D33MoXcwSx3n_AzMq9k%3D%3Dc-GEcY5Ubeu--6kmXg%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.



--
Raja
rajasaur at gmail.com

Traun Leyden

unread,
Oct 12, 2016, 1:50:34 PM10/12/16
to mobile-c...@googlegroups.com

I don't have a good answer on the dynamic channels issue, but I've forwarded that internally to make sure everyone sees it.

Also, to migrate data from CouchDB -> Sync Gateway you can use the internal replicator in CouchDB to push the data to Sync Gateway, since Sync Gateway supports the CouchDB replication protocol.



Reply all
Reply to author
Forward
0 new messages