From 86eb14d2e6f4f753a07298341513336cef0e3f7f Mon Sep 17 00:00:00 2001 From: Harish Krishna Date: Wed, 21 Jan 2015 17:51:03 -0500 Subject: [PATCH] making sure multiple suggesters and their index are not overwritten --- query/suggest.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/query/suggest.js b/query/suggest.js index 9d81da05..a61f9582 100644 --- a/query/suggest.js +++ b/query/suggest.js @@ -48,19 +48,21 @@ function generate( params, query_mixer, fuzziness ){ }; var cmd = new CmdGenerator(params); + var suggester_index = 0; + if (query_mixer && query_mixer.length) { query_mixer.forEach(function(item, index){ var expanded_layers = get_layers(item.layers); if (item.precision && Array.isArray( item.precision ) && item.precision.length ) { 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 { - cmd.add_suggester(index, undefined, expanded_layers, item.fuzzy); + cmd.add_suggester(suggester_index++, undefined, expanded_layers, item.fuzzy); } }); } else { - cmd.add_suggester(0); + cmd.add_suggester(suggester_index++); }