ViewQuery.endKeyDocId - unexpected result

Hi guys!
Currently I am implementing in my new project Java SDK 2.0 with async bucket.
Found some unexpected behavior with ViewQuery.endKeyDocId.
When I trying to set endKeyDocId (also startKeyDocId) -> the query result is empty.
The same action via web interface of Couchbase server 3.0 -> return results.
After short investigation I found that in Java object endKeyDocId value wrapped with quotes, but in web interface -> not.

P.S. Hope the version with the critical bug fixes will be published in the near feature.

Thanks !

Hi glassfox,

we are heavily working on a 2.0.1 release which will round of the rough edges of such a large new release.
In order we can track this down more quickly, can you please share your code, what is actually happening and the outcome?
Thanks much,
Michael

Following the code:

public static Observable<Long> deleteUntil(AsyncBucket bucket, Long accountId, Long lastId){
            ViewQuery query = ViewQuery
            .from("pending_items", "by_account_id")
            .key(accountId).inclusiveEnd()
            .endKeyDocId(getPendingItemLid(lastId));
            
            return bucket.query(query)
                    .flatMap(view -> 
                    view.rows())
                    .flatMap(row -> 
                        bucket.remove(JsonLongDocument.create(row.id(), Long.valueOf(((JsonObject)row.value()).get("id").toString()))))
                    .map(d -> 
                    d.content());
    }

Thanks!

Can you also share the expected values in those methods (you were referring to quoted/unquoted)

Also, some minor remarks for you code:

  • You can use java 8 method references like .flatMap(AsyncViewResult::rows())
  • Use bucket.remove(row.id()) directly, no need to create a full document just for removal.

Oh I think I see what you’re saying. Apparently we should not quote start/endKeyDocID - I’ll raise a ticket and fix that.

Ooops. I wrote a lot to explain the issue but your got it before :slight_smile:

You can use java 8 method references like .flatMap(AsyncViewResult::rows())

Thanks! This is my first experience with Java 8

Use bucket.remove(row.id()) directly, no need to create a full document just for removal.

I specially build the Json object for result → as you can see in below function, the output value is Id’s of all deleted items.
Also here I found some minor issue: Originally “id” of serialized object has been Long → but after de-serialization to JsonObject → getLong(“id”) return Exception but getInt(id") work fine. So I did a workaround with getObject(“id”).toString() and convert it to Long

Gotcha! Good to know. Found the bug already -> http://www.couchbase.com/issues/browse/JCBC-587

this is an easy fix, so it will be done very soon and part of 2.0.1!

Can you try this 2.0.1-pre version and see if it works for you?

https://dl.dropboxusercontent.com/u/10007675/Couchbase-Java-Client-2.0.1-SNAPSHOT-b0921ce.zip

I see.
Now you have “regression” with string values. (Or any value that required quotes wrapping)

Hmm, can you please elaborate? I talked to our view engineers and they said those two fields should never be quoted, its not JSON.

Or are you referring to a key that contains “” as part of its chars? Because we still do proper encoding of those fields. Can you give me an example that won’t work?

Sorry!
My mistake. Working perfect.

great! glad to hear it works now - don’t forget to upgrade to 2.0.1 once released