Last active
December 16, 2015 18:29
-
-
Save pulkitsinghal/5477903 to your computer and use it in GitHub Desktop.
MAP products bought together in CouchDB and create facets via REDUCE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function(doc) { | |
if (doc.type === "sale") { | |
if (doc.register_sale_products && doc.register_sale_products.length>1) { | |
for (var i=0; i < doc.register_sale_products.length; i++) { | |
for (var j=0; j < doc.register_sale_products.length; j++) { | |
if (i != j) { | |
emit([doc.register_sale_products[i].name, | |
doc.register_sale_products[j].name], | |
1) | |
}}}}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function(keys, values) { | |
return sum(values); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment