To create a 'primary key' index, i.e. an index that contains a list of every document within the database, with the document ID as the key, you can create a simple view:
function(doc,meta) { emit(meta.id,null); }
This enables you to iterate over the documents stored in the database.
This will provide you with a view that outputs the document ID of every document in the bucket using the document ID as the key.
The view can be useful for obtaining groups or ranges of documents based on the document ID, for example to get documents with a specific ID prefix:
?startkey="object"&endkey="object\u0000"Or to obtain a list of objects wtihin a given range:
?startkey="object100"&endkey="object199"For all views, the document ID is automatically included as part of the view response. But the without including the document ID within the key emitted by the view, it cannot be used as a search or querying mechanism.