diff --git a/src/components/templates/Search/utils.ts b/src/components/templates/Search/utils.ts index 751329908..26bfb1343 100644 --- a/src/components/templates/Search/utils.ts +++ b/src/components/templates/Search/utils.ts @@ -93,7 +93,7 @@ export function getSearchQuery( 'service.attributes.additionalInformation.tags' ] return { - from: (Number(page) || 0) * (Number(offset) || 21), + from: (Number(page) - 1 || 0) * (Number(offset) || 21), size: Number(offset) || 21, query: { bool: { diff --git a/src/utils/aquarius.ts b/src/utils/aquarius.ts index 75d499ee1..707289ebd 100644 --- a/src/utils/aquarius.ts +++ b/src/utils/aquarius.ts @@ -63,8 +63,11 @@ export function transformQueryResult( (hit: any) => new DDO(hit._source as DDO) ) result.totalResults = queryResult.hits.total - result.totalPages = Math.floor(result.totalResults / size) - result.page = from ? from / size : 1 + result.totalPages = + result.totalResults / size < 1 + ? Math.floor(result.totalResults / size) + : Math.ceil(result.totalResults / size) + result.page = from ? from / size + 1 : 1 return result } @@ -89,7 +92,6 @@ export async function queryMetadata( { cancelToken } ) if (!response || response.status !== 200 || !response.data) return - return transformQueryResult(response.data, query.from, query.size) } catch (error) { if (axios.isCancel(error)) { @@ -239,7 +241,7 @@ export async function getPublishedAssets( accesType = accesType || 'access OR compute' const queryPublishedAssets = { - from: (Number(page) || 0) * (Number(9) || 21), + from: (Number(page) - 1 || 0) * (Number(9) || 21), size: Number(9) || 21, query: { query_string: {