Browse Source

making sure multiple suggesters and their index are not overwritten

pull/65/head
Harish Krishna 10 years ago
parent
commit
86eb14d2e6
  1. 8
      query/suggest.js

8
query/suggest.js

@ -48,19 +48,21 @@ function generate( params, query_mixer, fuzziness ){
}; };
var cmd = new CmdGenerator(params); var cmd = new CmdGenerator(params);
var suggester_index = 0;
if (query_mixer && query_mixer.length) { if (query_mixer && query_mixer.length) {
query_mixer.forEach(function(item, index){ query_mixer.forEach(function(item, index){
var expanded_layers = get_layers(item.layers); var expanded_layers = get_layers(item.layers);
if (item.precision && Array.isArray( item.precision ) && item.precision.length ) { if (item.precision && Array.isArray( item.precision ) && item.precision.length ) {
item.precision.forEach(function(precision) { item.precision.forEach(function(precision) {
cmd.add_suggester(index, precision, expanded_layers, item.fuzzy); cmd.add_suggester(suggester_index++, precision, expanded_layers, item.fuzzy);
}); });
} else { } else {
cmd.add_suggester(index, undefined, expanded_layers, item.fuzzy); cmd.add_suggester(suggester_index++, undefined, expanded_layers, item.fuzzy);
} }
}); });
} else { } else {
cmd.add_suggester(0); cmd.add_suggester(suggester_index++);
} }

Loading…
Cancel
Save