client/public/src/models/CollectionModel.js
/**
   * @method convertElementQuery
   * @description Converts the simplified query object used by the html element into the format used by the API
   * @param {Object} elementQuery - Query object that mirrors element UI
   * 
   * @returns {Object} - Query object to be passed to API
   */
@method convertElementQuery
@description Converts the simplified query object used by the html element into the format used by the API
@param {Object} elementQuery - Query object that mirrors element UI

@returns {Object} - Query object to be passed to API
@method convertElementQuery @description Converts the simplified query object used by the html element into the format used by the API @param { Object } elementQuery - Query object that mirrors element UI @returns { Object } - Query object to be passed to API
convertElementQuery(elementQuery={}){
    let query = QueryUtils.getBaseQueryObject();
    if (Object.keys(elementQuery).length == 0) return query;
    let mainFacet = AssetDefs.facetExists(elementQuery.mainFacet) ? elementQuery.mainFacet : AssetDefs.defaultFacetId;
    let subFacet = AssetDefs.subFacetExists(mainFacet, elementQuery.subFacet) ? elementQuery.subFacet : AssetDefs.defaultFacetId;
    if ( mainFacet != AssetDefs.defaultFacetId && subFacet != AssetDefs.defaultFacetId ) {
      query.filters['@type'] = QueryUtils.getKeywordFilter([
        AssetDefs.getMainFacetById(mainFacet).es,
        AssetDefs.getSubFacetById(mainFacet, subFacet).es
      ]);
    }
    else if( mainFacet != AssetDefs.defaultFacetId ) {
      query.filters = AssetDefs.getMainFacetById(mainFacet).baseFilter;
    }
    if ( elementQuery.subjectFilter ) {
      query.filters[AssetDefs.getAreaField(mainFacet)] = QueryUtils.getKeywordFilter(
        QueryUtils.appendIdPrefix(elementQuery.subjectFilter)
      );
    }
    let c1 = elementQuery.azSelected && elementQuery.azSelected.toLowerCase() != AssetDefs.defaultAzId;
    let c2 = mainFacet != AssetDefs.defaultFacetId;
    if (c1 && c2) query.filters[AssetDefs.getAzAggField(mainFacet)]= QueryUtils.getKeywordFilter(elementQuery.azSelected);
    if (elementQuery.textQuery) {
      query.text = elementQuery.textQuery;
      query.textFields = AssetDefs.getSearchFields(mainFacet);
    }
    else {
      let s = {};
      s[AssetDefs.getBrowseSortField(mainFacet)] = 'asc';
      query.sort = [s];
    }
    query.facets = QueryUtils.defaultTypeFacet;
    if (elementQuery.offset) {
      query.offset = elementQuery.offset;
    }
    else if (elementQuery.pgCurrent) {
      let pg = this.pgPer;
      if (elementQuery.pgPer) pg = elementQuery.pgPer;
      query.offset = elementQuery.pgCurrent * pg - pg;
    }
    return query;
  }
convertElementQuery ( elementQuery = { } ) { let query = QueryUtils . getBaseQueryObject ( ) ; if ( Object . keys ( elementQuery ) . length == 0 ) return query ; let mainFacet = AssetDefs . facetExists ( elementQuery . mainFacet ) ? elementQuery . mainFacet : AssetDefs . defaultFacetId ; let subFacet = AssetDefs . subFacetExists ( mainFacet , elementQuery . subFacet ) ? elementQuery . subFacet : AssetDefs . defaultFacetId ; if ( mainFacet != AssetDefs . defaultFacetId && subFacet != AssetDefs . defaultFacetId ) { query . filters [ '@type' ] = QueryUtils . getKeywordFilter ( [ AssetDefs . getMainFacetById ( mainFacet ) . es , AssetDefs . getSubFacetById ( mainFacet , subFacet ) . es ] ) ; } else if ( mainFacet != AssetDefs . defaultFacetId ) { query . filters = AssetDefs . getMainFacetById ( mainFacet ) . baseFilter ; } if ( elementQuery . subjectFilter ) { query . filters [ AssetDefs . getAreaField ( mainFacet ) ] = QueryUtils . getKeywordFilter ( QueryUtils . appendIdPrefix ( elementQuery . subjectFilter ) ) ; } let c1 = elementQuery . azSelected && elementQuery . azSelected . toLowerCase ( ) != AssetDefs . defaultAzId ; let c2 = mainFacet != AssetDefs . defaultFacetId ; if ( c1 && c2 ) query . filters [ AssetDefs . getAzAggField ( mainFacet ) ] = QueryUtils . getKeywordFilter ( elementQuery . azSelected ) ; if ( elementQuery . textQuery ) { query . text = elementQuery . textQuery ; query . textFields = AssetDefs . getSearchFields ( mainFacet ) ; } else { let s = { } ; s [ AssetDefs . getBrowseSortField ( mainFacet ) ] = 'asc' ; query . sort = [ s ] ; } query . facets = QueryUtils . defaultTypeFacet ; if ( elementQuery . offset ) { query . offset = elementQuery . offset ; } else if ( elementQuery . pgCurrent ) { let pg = this . pgPer ; if ( elementQuery . pgPer ) pg = elementQuery . pgPer ; query . offset = elementQuery . pgCurrent * pg - pg ; } return query ; }
@method convertElementQuery
 @description Converts the simplified query object used by the html element into the format used by the API
 @param {Object} elementQuery - Query object that mirrors element UI
@method convertElementQuery @description Converts the simplified query object used by the html element into the format used by the API @param { Object } elementQuery - Query object that mirrors element UI
// Apply primary facets // Apply subject filter // Apply a-z filters // Apply search text query filter // No search text query. Just sort by label // Apply faceting to query // Apply pagination