Browse Source

removing poi3 (mostly redundant) - deduping the results

msv2
Harish Krishna 10 years ago
parent
commit
6b192d598d
  1. 18
      controller/suggest.js

18
controller/suggest.js

@ -42,10 +42,6 @@ function setup( backend, query ){
cmd.body = query_poi( req.clean );
query_backend(cmd, callback);
},
poi3: function(callback){
cmd.body = query_poi( req.clean, 3 );
query_backend(cmd, callback);
},
poi1: function(callback){
cmd.body = query_poi( req.clean, 1 );
query_backend(cmd, callback);
@ -53,8 +49,18 @@ function setup( backend, query ){
},
function(err, results) {
// results is now equals to: {admin: docs, poi: docs, poi1: docs, poi3: docs}
var combined = results.poi.concat(results.admin).concat(results.poi1).concat(results.poi3);
var combined = results.poi.splice(0,3).concat(results.admin.splice(0,4)).concat(results.poi1.splice(0,4));
//dedup
var unique_ids = [];
combined = combined.filter(function(item, pos) {
if (unique_ids.indexOf(item.payload.id) == -1) {
unique_ids.push(item.payload.id);
return true;
}
return false;
});
// convert docs to geojson
var geojson = geojsonify( combined );

Loading…
Cancel
Save