Do filter/byChannel and style=all_docs go well together?

Hi

I try to listen to changes feed on specific channel (lets call it channelA), but the document has conflicts and the winning revision does not belong to the channel. But non winning leaf revision does.

When querying the changes feed with params style=all_docs&active_only=true&include_docs=false&filter=sync_gateway%2Fbychannel&channels=channelA i get no results.

The document revision tree looks like this:

1-77635e (no channels)  __
|                          \
2-4f0444 (no channels)     2-1b3ef4 (channelA)
|
3-c3611d (no channels)

This is the document’s _sync metadata:

"_sync": {
    "rev": "3-c3611d",
    "flags": 24,
    "sequence": 139,
    "recent_sequences": [
      136,
      137,
      138,
      139
    ],
    "history": {
      "revs": [
        "1-77635e",
        "2-4f0444",
        "2-1b3ef4",
        "3-c3611d"
      ],
      "parents": [
        -1,
        0,
        0,
        1
      ],
      "bodymap": {
        "2": "{\"syncedBy\":\"someUser\"}"
      },
      "channels": [
        null,
        null,
        [
          "channelA"
        ],
        null
      ]
    },
    "time_saved": "2017-06-06T09:02:25.869178522Z"
  },

It looks to me like only the winning revision is verified against the byChannel filter and only if it matches all remaining conflicts are included in the response (if requested by style param).

We are using version 1.3.

Is there a way to listen for all leafs on specific channel, other than making a change request w/o filter and manually checking individual docs’ channel info?

1 Like

That sounds like correct behavior.

Yes, this sounds like the way it was intended to be designed.

Not that I know of.

What about preventing the winning revision of the doc from losing the channel? That seems like it would fix your issue, since the doc will still show up in the changes feed?

That would fix the issue, but we don’t want that specific revision in the channel.

We worked around it by creating a Couchbase view that analyzes _sync part of document and extracts leafs that are of interest to us. It shouldn’t be a big setback in terms of performance I quess.