From 8aa6b3997ab484c1e3187af1133022bee7349874 Mon Sep 17 00:00:00 2001 From: mihaisc Date: Wed, 16 Mar 2022 17:12:09 +0200 Subject: [PATCH] Fix compute dataset algorithm list (#1194) * fix query Signed-off-by: mihaisc * remove comment Signed-off-by: mihaisc --- src/@utils/aquarius.ts | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/@utils/aquarius.ts b/src/@utils/aquarius.ts index 67eb3c88e..e34500ae7 100644 --- a/src/@utils/aquarius.ts +++ b/src/@utils/aquarius.ts @@ -11,6 +11,12 @@ import { transformAssetToAssetSelection } from './assetConvertor' export const MAXIMUM_NUMBER_OF_PAGES_WITH_RESULTS = 476 +export function escapeEsReservedCharacters(value: string): string { + // eslint-disable-next-line no-useless-escape + const pattern = /([\!\*\+\-\=\<\>\&\|\(\)\[\]\{\}\^\~\?\:\\/"])/g + return value.replace(pattern, '\\$1') +} + /** * @param filterField the name of the actual field from the ddo schema e.g. 'id','service.attributes.main.type' * @param value the value of the filter @@ -227,12 +233,15 @@ export async function getAlgorithmDatasetsForCompute( ): Promise { const baseQueryParams = { chainIds: [datasetChainId], - filters: [ - getFilterTerm( - 'service.compite.publisherTrustedAlgorithms.did', - algorithmId - ) - ], + nestedQuery: { + must: { + match: { + 'services.compute.publisherTrustedAlgorithms.did': { + query: escapeEsReservedCharacters(algorithmId) + } + } + } + }, sortOptions: { sortBy: SortTermOptions.Created, sortDirection: SortDirectionOptions.Descending