diff --git a/medicines/web/.env b/medicines/web/.env index ba427669b..6a8a15555 100644 --- a/medicines/web/.env +++ b/medicines/web/.env @@ -1,6 +1,6 @@ -// .env -AZURE_API_VERSION=2017-11-11 -AZURE_INDEX=azureblob-index -AZURE_KEY=6D6107C925CC3C284A9218EFC626C7F7 -AZURE_SERVICE=rb-mhra-mip -AZURE_WORD_FUZZINESS=1 +//.env +AZURE_SEARCH_API_VERSION=2017-11-11 +AZURE_SEARCH_INDEX=azureblob-index +AZURE_SEARCH_KEY=6D6107C925CC3C284A9218EFC626C7F7 +AZURE_SEARCH_SERVICE=rb-mhra-mip +AZURE_SEARCH_WORD_FUZZINESS=1 \ No newline at end of file diff --git a/medicines/web/src/components/mip/azure-search.ts b/medicines/web/src/components/mip/azure-search.ts index ade9d92cc..ba74a58ba 100644 --- a/medicines/web/src/components/mip/azure-search.ts +++ b/medicines/web/src/components/mip/azure-search.ts @@ -1,8 +1,8 @@ -const azureApiVersion = process.env.AZURE_API_VERSION; -const azureIndex = process.env.AZURE_INDEX; -const azureKey = process.env.AZURE_KEY; -const azureService = process.env.AZURE_SERVICE; -const azureWordFuzziness = process.env.AZURE_WORD_FUZZINESS; +const azureSearchApiVersion = process.env.AZURE_SEARCH_API_VERSION; +const azureSearchIndex = process.env.AZURE_SEARCH_INDEX; +const azureSearchKey = process.env.AZURE_SEARCH_KEY; +const azureSearchService = process.env.AZURE_SEARCH_SERVICE; +const azureSearchWordFuzziness = process.env.AZURE_SEARCH_WORD_FUZZINESS; enum DocType { PilLabel, @@ -23,7 +23,7 @@ const escapeSpecialCharacters = (word: string): string => word.replace(/([+\-!(){}\[\]^"~*?:\/]|\|\||&&)/gi, `\\$1`); const addAzureWordFuzziness = (word: string): string => - `${word}~${azureWordFuzziness}`; + `${word}~${azureSearchWordFuzziness}`; const buildFuzzyQuery = (query: string): string => { return query @@ -35,11 +35,11 @@ const buildFuzzyQuery = (query: string): string => { const buildAzureSearchUrl = (query: string): string => { const url = new URL( - `https://${azureService}.search.windows.net/indexes/${azureIndex}/docs`, + `https://${azureSearchService}.search.windows.net/indexes/${azureSearchIndex}/docs`, ); - url.searchParams.append('api-key', azureKey as string); - url.searchParams.append('api-version', azureApiVersion as string); + url.searchParams.append('api-key', azureSearchKey as string); + url.searchParams.append('api-version', azureSearchApiVersion as string); url.searchParams.append('highlight', 'content'); url.searchParams.append('queryType', 'full'); url.searchParams.append('search', query); diff --git a/medicines/web/src/components/mip/index.tsx b/medicines/web/src/components/mip/index.tsx index da068a753..b70908119 100644 --- a/medicines/web/src/components/mip/index.tsx +++ b/medicines/web/src/components/mip/index.tsx @@ -71,7 +71,7 @@ const Mip: React.FC = () => { setResults( (await azureSearch(search)).map((drug: IAzureSearchResult) => ({ name: drug['@search.highlights'].content.join(' … '), - url: '', + url: atob(drug.metadata_storage_path), })), ); };