Couchbase Lite Pull With Filtered Replication From Couchdb
Solution 1:
Unfortunately, Couchbase lite only allows filtered pull replications when the backend is Couchbase Server.
You cannot perform a filtered replication when the backend is CouchDB, Cloudant or anything else.
Filtered pull from CouchDB, PouchDB or Cloudant Since Couchbase Lite 1.2, filter functions in pull replications with non-Couchbase databases are no longer available. There is an incompatibility in the way the filter parameter is handled in the POST /{db}/_changes request (see #1139).
Solution 2:
Using filter params in query string is not a correct way to implement as query string has its own limitation. Instead one should use selector instead of filter if you are using CouchDB Server 2.0 and above. Only thing you need to make sure at your client side is, set the filter name = _selector and in filter params, pass params in following format -
{
"selector": {
"key_name_to_filter": "key_value_to_filter",
"$or": [
{
"$and": [
{
"key_1": "value_1"
},
{
"key_2": "value2"
}
]
},
{
"$and": [
{
"key_3": "value_3"
},
{
"key_4": "value_4"
}
]
}
]
}
}
Above format is just an example illustrating you can create complex queries in selector filter.
Solution 3:
Couchbase-lite filters will not work with any other server apart from Couchbase. The reason for the same is that in CouchDb, the _changes REST call is a GET request whereas going ahead from version 1.2, Couchbase-lite has converted the request to POST. One way could be to fork the repository and make the changes in ChangeTracker.java and change the usePOST boolean variable to false and you will see it starts to work. But then this is the path that Couchbase has chosen and going forward from version 2.0, the support for all non-Couchbase Backends will totally be removed because they will completely move away from http.
Post a Comment for "Couchbase Lite Pull With Filtered Replication From Couchdb"