I believe this is a question about Couchbase Lite, and not Couchbase Server, so I’m moving it over to that topic, and I’m tagging some of the engineers who might be able to help.
If you want help you will need to post a complete picture of what you are doing. You have several variables in there that are unknown to us. Try to format your post with the following items:
A complete runnable example (including any documents that need to be inserted)
The expected results
The actual results
Without that all we can do is go back and forth with more and more head scratching.