How can I view what a view's map function emits for a single document?


#1

I would like to be able to look at the output of a view’s map function for a specific document to assist in view development/testing/debugging. Seems like simple thing, but I can’t figure out how to do it. Is this possible?


#2

Try querying using the following params. This will have to be done on the full dataset to ensure that you get an accurate result.

startkey_docid={desiredDocId}&endkey_docid={desiredDocId}&inclusive_end=true&stale=false

#3

You can query a specific key from a view via the key parameter. Somthing like this works in node.js for example but it will be similar in all other SDKs

var options = { key: "bla" } var query = bucket.view("test", "foo", options) query.query(function (err, results) { if(err) console.log(err) console.log(results) })

#4

Specifying a value for key returns all values for the given key.

I’m trying to get all key/values emitted by the map function for a single document /em>.

Specifying startkey_docid and endkey_docid seems like the way to go, but any values I supply seem to be ignored.

For example, the two URLs below give the results:

http://localhost:8092/beer-sample/_design/beer/_view/brewery_beers?startkey_docid=bear_republic_brewery-xp_pale_ale&endkey_docid=bear_republic_brewery-xp_pale_ale
http://localhost:8092/beer-sample/_design/beer/_view/brewery_beers


#5

If I understand right what you want to do I fear that startkey_docid is not the option you want, for more explanation about this parameter I can refer you to this post. Those parameters work in conjuction with startkey and so forth to make pagination work.

I think the easiest way to take a look at what kind of keys are generated is to move the document to a bucket and copy the map reduce functions over as well and look what kind of indicies are created. Also whenever you are in doubt on how a specific url to query should look like you can use the webinterface to build the query you want and copy the URL as it is linked.