I am trying to get the count of a nested array element. I know that this can be done easily using N1QL but that is not an option for performance reasons. While exploring the sub-document api, I came across AsyncLookupInBuilder.getCount but it seems to only be available in couchbase server 5.0 (we use 4.5). Aside from pulling back the entire document and processing it in memory, is there another way I can achieve this objective?
As you identified, getCount() was added in 5.0. If you can’t upgrade (and need to use K/V) you’ll have to pull the document down and parse it yourself.
One alternative would be to define a map/reduce view which calculates the number of elements in your nester array.