use SAMPLE db.label.insertMany ([{first_label: 'a', second_label: 'a', label_id: 1}, {first_label:'a', second_label: 'b',label_id: 2}, {first_label:'a', second_label: 'c',label_id: 3}, {first_label:'b', second_label: 'b',label_id: 4}, {first_label:'b ', second_label: 'c',label_id: 5}, {first_label:'c', second_label: 'c',label_id: 6}]); db.label.createIndex({label_id: 1}); db.color.insertMany ([{color: 'red', color_id : 1}, {color: 'green', color_id : 2}, {color: 'blue', color_id :3}]); db.color.createIndex({color_id: 1}); db.color.createIndex({color: 1}); db.label_color_hit.insertMany ( [{label_id: 1, color_id: 1, hits: 1, hit_time: '2000-01-01'}, {label_id: 2, color_id: 2, hits: 2, hit_time: '2002-02-02'}, {label_id: 3, color_id: 3, hits: 3, hit_time: '2003-03-03'}, {label_id: 4, color_id: 1, hits: 4, hit_time: '2004-04-04'}, {label_id: 5, color_id: 2, hits: 5, hit_time: '2005-05-05'} ]); db.label_color_hit.insertMany ( [ {label_id: 1, color_id: 1, hits: 10, hit_time: '2010-01-01'}, {label_id: 2, color_id: 2, hits: 20, hit_time: '2012-02-02'}, {label_id: 3, color_id: 3, hits: 30, hit_time: '2013-03-03'}, {label_id: 4, color_id: 1, hits: 40, hit_time: '2014-04-04'}, {label_id: 5, color_id: 2, hits: 50, hit_time: '2015-05-05'} ]); db.label_color_hit.createIndex({label_id:1, color_id: 1}); db.label_color_hit.createIndex({color_id: 1});