It is possible, but you need to create a view for this (secondary index).
You can create a view in the couchbase web console as follows:
function (doc, meta) { if(meta.type == "json") { emit(null); } }
This will emit all the keys (the keys will automatically exit anyway, so there is no need to include anything extra).
You can then request a view, as shown below, using java sdk. (Obviously you need to instantiate a couchbase client, etc.)
View view = couchbaseClient.getView("DESIGN_VIEW NAME", "VIEW_NAME"); Query query = new Query(); ViewResponse viewResponse = couchbaseClient.query(view, query); List<String> keys = new ArrayList<String>(); for (ViewRow viewRow : viewResponse) { keys.add(viewRow.getKey()); }
scalabilitysolved
source share