List all keys (CB 2.2)

21 views
Skip to first unread message

Istvan Szukacs

unread,
Nov 4, 2014, 4:55:13 PM11/4/14
to couc...@googlegroups.com
Hi,

What is the best way of listing all of the keys either by command line tool or using the SDK (preferably a language like Python or Ruby).

Thanks,
Istvan

nobody nowhere

unread,
Jan 12, 2015, 6:26:18 AM1/12/15
to couc...@googlegroups.com
We made a view
function (doc, meta) {
    emit(meta.id, null);
}

среда, 5 ноября 2014 г., 0:55:13 UTC+3 пользователь Istvan Szukacs написал:

Warren Lindsey

unread,
Jan 13, 2015, 4:02:45 PM1/13/15
to couc...@googlegroups.com
Hello Istvan,

Couchbase 2.5.x has a hidden view named "_all_docs" which will do what you want.  The view was removed from 3.x

From the command line you could curl it:


Change mybucket to whatever your bucket name is, possibly default.  Result looks like:

{
  "total_rows":9949305,
  "rows":[
    {
      "id":"my_key_name",
      "key":"my_key_name",
      "value":{
        "rev":"1-000eb5b7f7f48a250000000000000000"
      }
    },
...
  ]
}

Cheers,
Warren

--
You received this message because you are subscribed to the Google Groups "Couchbase" group.
To unsubscribe from this group and stop receiving emails from it, send an email to couchbase+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Aliaksey Kandratsenka

unread,
Jan 13, 2015, 4:11:24 PM1/13/15
to couc...@googlegroups.com
On Tue, Jan 13, 2015 at 1:02 PM, Warren Lindsey <warren....@gmail.com> wrote:
Hello Istvan,

Couchbase 2.5.x has a hidden view named "_all_docs" which will do what you want.  The view was removed from 3.x

Please note that _all_docs was never high-performance enough solution. If you really need sorted list of docs there's no other way but views (and even with views perf might still be a problem depending on your mutation rates and query rates).

If you can tolerate unsorted list of docs, then other options are possible. I.e. TAP or DCP. But note that AFAIK both are not as of now officially supported for "external consumption". And TAP is deprecated of course in favor of DCP.

If you're willing to deal with lower-level (and unsupported too) options, you can build something on top of couch_dbdump (or on code of couch_dbdump) reading data files directly. That's what _all_docs did in fact, but due to requirement of sorted output, it was far less efficient than simply iterating over all vbuckets and all docs within each vbucket.

Reply all
Reply to author
Forward
0 new messages