Couchbase lite compound key range with nulls android

java

#1

I have view for my weather data with compound keys of the format

[ "District", "2018", "05", "23", "06", "00", "00" ]
On the server i can query weather for a day using a startkey and endkey

startkey=[ "District","2018","05","23",null,null,null]
endkey=[ "District","2018","05","23","\u0fff","\u0fff","\u0fff"]

This gives me all the weather for District on 2018-05-23. Now after syncing the documents to couchbase lite on android, i’m trying to replicate the key ranges. I have tried

startkey=arrayListOf("District","2018","05","23",null,null,null)
endkey=arrayListOf("District","2018","05","23","\u0fff","\u0fff","\u0fff")

But this returns an empty dataset. How can i format my keys to replicate what i did on the server.


#2

It’s been a while since I dealt with this, but I believe that the correct representation on the mobile side is:

startKey=arrayListOf("District","2018","05","23")
endKey=arrayListOf("District","2018","05","23", <empty dict>, <empty dict>, <empty dict>)

Forgive the pseudocode there but what I mean is an empty dictionary object (not a string at all) since those get sorted last

EDIT Though perhaps the Unicode string will work if you omit the nulls from the start key


#3

Even omitting the nulls didn’t help. Instead i decided to use the format
startkey=arrayListOf(“District”,“2018”,“05”,“23”,“99”,“99”,“99”)
endkey=arrayListOf(“District”,“2018”,“05”,“23”,“00”,“00”,“00”)
Since the last three are time values, it’s working for now. But replicating what i did on the server has completely failed.