I have a view
function(doc) {
if (doc.type == "XXXXX") {
emit(doc.name, 1);
}
}
Is it possible to change it so that the view only emits that doc.name if already doesn't exist? I'm fully aware that you have the reduce function; however, it still slows done the initial build of the view.
Thanks in advance
Check out couchdb reduce grouping . I think if your view did this for emit:
emit(doc_name,1)
and your reduce function was _sum, you could query this map/reduce view with group=true
Fundamentally, the map function only has the context of the document that is passed into it. The only possible optimisation is an Erlang native view (or Cloudant Query - note that reduce is not currently exposed though).
I think the only way is to use reduce, then for niceness dbcopy:
"map": emit(doc.name, 1);
"reduce": return keys[0];
"dbcopy": "unique_names"
This way you have a new pre-computed database called "unique_names" of only unique items.
I don't think it's possible without reduce as your question requests.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.