Is it possible to start PullReplication with mulitple filters - Couchbase Lite Android?

54 views
Skip to first unread message

Pankaj Jakhar

unread,
Feb 13, 2014, 3:47:39 AM2/13/14
to mobile-c...@googlegroups.com


Can I use multiple filters in PullReplication?

Like I am trying to do so. 

mDatabase.setFilter("filterOne", new ReplicationFilter() {
@Override
public boolean filter(SavedRevision savedRevision, Map<String, Object> map) {
// TODO Auto-generated method stub
return false;
}
});
mDatabase.setFilter("filterTwo", new ReplicationFilter() {
@Override
public boolean filter(SavedRevision savedRevision, Map<String, Object> map) {
// TODO Auto-generated method stub
return false;
}
});
mDatabase.setFilter("filterThree", new ReplicationFilter() {
@Override
public boolean filter(SavedRevision savedRevision, Map<String, Object> map) {
// TODO Auto-generated method stub
return false;
}
});
pullReplication.setFilter("filterOne");
pullReplication.setFilter("filterTwo");
pullReplication.setFilter("filterThree");

Will it work to set multiple filters individually? Is there any documentation for that?

or do we have any provision of doing so:

List<String> filters;
pullReplication.setFilters(filters);

Please make it clear to me.

Jens Alfke

unread,
Feb 13, 2014, 9:54:12 AM2/13/14
to mobile-c...@googlegroups.com
No, replications can only use one filter. If you need to combine filters, it's simple to create one that calls the others and combines their results.

—Jens

Pankaj Jakhar

unread,
Feb 17, 2014, 1:30:40 AM2/17/14
to mobile-c...@googlegroups.com
Okay so in this case, will I need to write a complex JS function on Server? 

Jens Alfke

unread,
Feb 17, 2014, 1:44:53 AM2/17/14
to mobile-c...@googlegroups.com

On Feb 16, 2014, at 10:30 PM, Pankaj Jakhar <pankaj...@gmail.com> wrote:

Okay so in this case, will I need to write a complex JS function on Server? 

Well, you'll need to write a filter function that combines the multiple filters you would have used, with "&&" between them.

—Jens

Pankaj Jakhar

unread,
Feb 17, 2014, 2:15:53 AM2/17/14
to mobile-c...@googlegroups.com
Thanks for quick reply. 

In CouchDB function is written as:

function(doc){
emit
(doc._id, null);
}

Where would I specify extra param in CouchDB which will accept filterparams?

Jens Alfke

unread,
Feb 17, 2014, 12:02:34 PM2/17/14
to mobile-c...@googlegroups.com

On Feb 16, 2014, at 11:15 PM, Pankaj Jakhar <pankaj...@gmail.com> wrote:

In CouchDB function is written as:

function(doc){
emit
(doc._id, null);
}

Where would I specify extra param in CouchDB which will accept filterparams?

That's a map function, which is for creating search indexes. It has nothing to do with filtering or replication.

Please see the CouchDB documentation for help on writing filter functions. We don't provide support for CouchDB here; if you need more help with using it, try their mailing list.

—Jens
Reply all
Reply to author
Forward
0 new messages