ViewQuery with startKey and endKey JsonArray

Hi,

When I attempt to query a view with at least 1 of the keys missing in a JsonArray the query fails and I managed to debug and find the reason why.

ViewQuery (com.couchbase.client.java.view.ViewQuery) generates a query with startKey=[] which is wrong, it should generate startKeys=[], the difference being the S on the end. If I manually run the query in my webbrowser and add and ‘s’ to after Key it works perfectly fine.

So in summary, the issue is that when I’m running the following code:
ViewQuery query = ViewQuery.from(“profile”, “profile_report”).stale(Stale.FALSE).limit(maxResults).startKey(JsonArray.from(startkey))
.endKey(JsonArray.from(endkey)).inclusiveEnd(true);

It will generate a query that has startKey & endKey instead of startKeys & endKeys.

Is this intended behavior and if so how do I get around it?

Never mind my question. I managed to solve this by having the optional parameter at the end of the emit. Instead of in the center.

1 Like