> 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.
Your design document has to look like this:
{
"views": {
"my_first_view": {
"map":"...",
"reduce":"..."
}
}
}
Below is an example in Ruby, which should be easy to rewrite as a shell
script which uses curl.
HTH,
Brian.
---- 8< ----
require 'rubygems'
require 'restclient'
require 'json'
DB="http://127.0.0.1:5984/collator"
RestClient.delete DB rescue nil
RestClient.put "#{DB}",""
(32..126).each do |c|
RestClient.put "#{DB}/#{c.to_s(16)}", {"x"=>c.chr}.to_json
end
RestClient.put "#{DB}/_design/test", <<EOS
{
"views":{
"one":{
"map":"function (doc) { emit(doc.x,null); }"
}
}
}
EOS
puts RestClient.get("#{DB}/_design/test/_view/one")