All,
So I was looking at the "View Snippets" page (ref: http://wiki.apache.org/couchdb/View_Snippets) and noted the curl command. I am using something similar but rather than on the command line I place the map reduce code in a file. So if I take the code Brian, sent me this morning and put it in a file in a manner like I have appended to the end of this email I can use something like:

curl -s -i -X POST -H 'Content-Type: application/json' --data @getFieldNamesv2.js 'http://xxx.xxx.xxx.xxx:5984/jcoresgarden/_temp_view?group=true'

rather than needing to place the .js in the command line argument directly. The question is... I've tried some combinations, but can't seem to get an approach that would allow me to post the map reduce code to a _design document rather than just a _temp_view as in this example.

Is it possible, once you have a map reduce code you like and tested against a small test data set to then POST it via curl for example, against the production database or do you have to place the design documents in via the gui?

Thanks
Doug

Thanks again to Brian, Chris and Blair for your help on that "find unique fields..." thread

-------- start file--------
{
"map":
"function(doc) {
 for (var key in doc) {
  emit(key,null)
 }
}",
"reduce":
"function(ks, vs, co) {
 if (co) {
   var result = vs.shift();
   for (var i in vs) {
     for (var j in vs[i]) {
       result[j] = (result[j] || 0) + vs[i][j];
     }
   }
   return result;
 } else {
   var result = {};
   for (var i in ks) {
     var key = ks[i];
     result[key[0]] = (result[key[0]] || 0) + 1;
   }
   return result;
 }
}"
}
--------- end file --------

Reply via email to