elastic-harvester.js
function getAggregationFields(query, aggParam, supplimentalBanList) {
    let retVal = [];
    const _aggParam = aggParam || 'aggregations';

    if (!query[_aggParam]) {
      return retVal;
    }
    const _supplimentalBanList = supplimentalBanList || {};

    _.each(query[_aggParam].split(','), (agg) => {
      assertAggNameIsAllowed(agg, _supplimentalBanList);
      _supplimentalBanList[agg] = true;
      let _type = query[`${agg}.type`];
      !_type && (_type = 'terms');
      const aggOptions = permittedAggOptions[_type];
      _.each(aggOptions, (aggOption) => {
        const expectedOptionName = `${agg}.${aggOption}`;
        retVal.push(expectedOptionName);
      });

      if (query[`${agg}.aggregations`]) {
        const nestedAggFields = getAggregationFields(query, `${agg}.aggregations`, _supplimentalBanList);
        retVal = retVal.concat(nestedAggFields);
      }
    });
    return retVal;
  }
function getAggregationFields(query, aggParam, supplimentalBanList) {
    let retVal = [];
    const _aggParam = aggParam || 'aggregations';

    if (!query[_aggParam]) {
      return retVal;
    }
    const _supplimentalBanList = supplimentalBanList || {};

    _.each(query[_aggParam].split(','), (agg) => {
      assertAggNameIsAllowed(agg, _supplimentalBanList);
      _supplimentalBanList[agg] = true;
      let _type = query[`${agg}.type`];
      !_type && (_type = 'terms');
      const aggOptions = permittedAggOptions[_type];
      _.each(aggOptions, (aggOption) => {
        const expectedOptionName = `${agg}.${aggOption}`;
        retVal.push(expectedOptionName);
      });

      if (query[`${agg}.aggregations`]) {
        const nestedAggFields = getAggregationFields(query, `${agg}.aggregations`, _supplimentalBanList);
        retVal = retVal.concat(nestedAggFields);
      }
    });
    return retVal;
  }
function getAggregationFields ( query , aggParam , supplimentalBanList ) { let retVal = [ ] ; const _aggParam = aggParam || 'aggregations' ; if ( ! query [ _aggParam ] ) { return retVal ; } const _supplimentalBanList = supplimentalBanList || { } ; _ . each ( query [ _aggParam ] . split ( ',' ) , ( agg ) => { assertAggNameIsAllowed ( agg , _supplimentalBanList ) ; _supplimentalBanList [ agg ] = true ; let _type = query [ ` ${ agg } ` ] ; ! _type && ( _type = 'terms' ) ; const aggOptions = permittedAggOptions [ _type ] ; _ . each ( aggOptions , ( aggOption ) => { const expectedOptionName = ` ${ agg } ${ aggOption } ` ; retVal . push ( expectedOptionName ) ; } ) ; if ( query [ ` ${ agg } ` ] ) { const nestedAggFields = getAggregationFields ( query , ` ${ agg } ` , _supplimentalBanList ) ; retVal = retVal . concat ( nestedAggFields ) ; } } ) ; return retVal ; }
returns an array of all protected aggregationFields
returns an array of all protected aggregationFields