Map and reduce queries in couchdb?

Up vote 0 down vote favorite share g+ share fb share tw.

I am newbie to write couchdb map and reduce queries. One of my requirements is based on some keys we have to emit the data. I wrote Successfully for that as mentioned below.

Function(doc) { emit(doc. Type , doc. Category, doc.

User, doc); } If we give three key values like http://localhost:5984/test/_design/myDesign/_view/myView? Key="Science","A","John" then that data will be emitted. But my doubt is how can I get the data if we give one key or two keys for that view.

That means for the above view if the user mentioned one key like doc. User then the user data will be emitted based on the three keys. And one more doubt is, Can we give two values for one key?

Suppose the user wants to get the data either user name is JOHN or Joe by using the same view. Please provide guidance to achieve. Thanks.

Couchdb link|improve this question asked Mar 24 at 7:53veerender71 100% accept rate.

You could change your view this way: emit(doc. User, doc. Type, doc.

Category, doc); and then ask for? Startkey="someName"&endkey="someName",{} then in the resultlist are all documents that have doc. User="someName", regardless of type and category if you need more specific informations, you can add another criteria to your call:?

Startkey="someName","someType"&endkey="someName","someType",{} then you receive all docs with someName AND someType. But you have to use the same order (key fields must be filled from left to right) if you need another order (look for only types), you have to do a second emit with the other order in the same function (or in another function). Asking for two keys at the same time is only possible with the hole key given.

Then you have to call a view py POST with body { keys="Science","A","John","Science","A","Joe" }.

Thanks for reply, { keys="Science","A","John","Science","A","Joe" } but it is not working , can you please provide the syntax for accessing the two values for the same view at a time – veerender Mar 26 at 13:19.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions