SIB-Colombia / bambu

New SiB Colombia dataportal API Backend
MIT License
1 stars 2 forks source link

ElasticSearch queries #3

Open andcastillo opened 7 years ago

andcastillo commented 7 years ago

Why do you use countAndQueries and counter??? Is it not easier to push ???

 if (req.swagger.params.kingdomName.value) {
    query.query.bool.must[countAndQueries] = {
      bool: {
        should: []
      }
    };
    let counter = 0;
    req.swagger.params.kingdomName.value.forEach((value) => {
      query.query.bool.must[countAndQueries].bool.should[counter] = {
        wildcard: {
          'taxonomy.kingdom_name.exactWords': `*${value.toLowerCase()}*`
        }
      };
      counter += 1;
    });
    countAndQueries += 1;
  }