addon/utils/discover-page.js
function buildQueryBody(queryParams, filters, queryParamsChanged) {
    let query = {
        query_string: {
            query: queryParams.q || '*',
        },
    };

    if (filters.length) {
        query = {
            bool: {
                must: query,
                filter: filters,
            },
        };
    }

    const queryBody = {
        query,
        from: (queryParams.page - 1) * queryParams.size,
        aggregations: elasticAggregations,
    };

    let sortValue = queryParams.sort;
    if (!queryParamsChanged) {
        sortValue = '-date_modified';
    }

    if (sortValue) {
        const sortBy = {};
        sortBy[sortValue.replace(/^-/, '')] = sortValue[0] === '-' ? 'desc' : 'asc';
        queryBody.sort = sortBy;
    }

    return JSON.stringify(queryBody);
}
function buildQueryBody(queryParams, filters, queryParamsChanged) {
    let query = {
        query_string: {
            query: queryParams.q || '*',
        },
    };

    if (filters.length) {
        query = {
            bool: {
                must: query,
                filter: filters,
            },
        };
    }

    const queryBody = {
        query,
        from: (queryParams.page - 1) * queryParams.size,
        aggregations: elasticAggregations,
    };

    let sortValue = queryParams.sort;
    if (!queryParamsChanged) {
        sortValue = '-date_modified';
    }

    if (sortValue) {
        const sortBy = {};
        sortBy[sortValue.replace(/^-/, '')] = sortValue[0] === '-' ? 'desc' : 'asc';
        queryBody.sort = sortBy;
    }

    return JSON.stringify(queryBody);
}
function buildQueryBody ( queryParams , filters , queryParamsChanged ) { let query = { query_string : { query : queryParams . q || '*' , } , } ; if ( filters . length ) { query = { bool : { must : query , filter : filters , } , } ; } const queryBody = { query , from : ( queryParams . page - 1 ) * queryParams . size , aggregations : elasticAggregations , } ; let sortValue = queryParams . sort ; if ( ! queryParamsChanged ) { sortValue = '-date_modified' ; } if ( sortValue ) { const sortBy = { } ; sortBy [ sortValue . replace ( / ^- / , '' ) ] = sortValue [ 0 ] === '-' ? 'desc' : 'asc' ; queryBody . sort = sortBy ; } return JSON . stringify ( queryBody ) ; }
Construct queryBody for OSF facets

@method buildQueryBody
@param {Object} queryParams - Ember Parachute queryParams
@param {List} filters - Filters for query body
@param {Boolean} queryParamsChanged - Whether or not any queryParams differ from their defaults
@return {String} queryBody - Stringified queryBody
Construct queryBody for OSF facets