Having tried filters for replication, I came across a problem. Although my filter works as an entry in the _replicator database, I do not use cURL.
Filter in the project document:
{
"_id": "_design/partial",
"filters": {
"mobile": "function(doc, req) {
if (doc._attachments) {
var result = new Boolean(true);
for (attachment in doc._attachments) {
if (attachment.content_type == 'image/jpeg') {
return true;
}
if (doc._attachments.length > 1024) {
result = false;
}
}
return result;
} else {
return true;
}
}"
}
}
CURL line:
curl -X POST http://admin:pass@192.168.178.13:5985/_replicate -d '{\"source\":\"http://admin:pass@192.168.2:5984/docs2\",\"target\":\"docs2_partial\",\"filter\":\"partial/mobile\",\"create_target\":true}' -H "Content-Type: application/json"
I created a _design / partial document for both the target and the source, but all documents are replicated. Even one that has an attached binary file larger than 1 MB. Any help is appreciated!
CURL answer:
{"ok":true,"session_id":"833ff96d21278a24532d116f57c45f31","source_last_seq":32,"replication_id_version":2,"history":[{"session_id":"833ff96d21278a24532d116f57c45f31","start_time":"Wed, 17 Aug 2011 21:43:46 GMT","end_time":"Wed, 17 Aug 2011 21:44:22 GMT","start_last_seq":0,"end_last_seq":32,"recorded_seq":32,"missing_checked":0,"missing_found":28,"docs_read":28,"docs_written":28,"doc_write_failures":0}]}
Using "instead of \" or "instead", the result:
{"error":"bad_request","reason":"invalid UTF-8 JSON: [...]}