From c5462c354d7f02ec42778379578e5941d501a2f9 Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Mon, 7 Oct 2024 21:40:57 +0800 Subject: [PATCH] fix(queryEnhancements): data.search() should not ignore the `strategy` passed as parameter (#8368) (#8495) * fix(queryEnhancements): data.search() should not ignore the `strategy` passed as parameter This is quick fix for the issue that the search strategy passed to data.search() API been completely ignored when query enhancement is enabled and the localStorage has a language preserved. For example, selecting a language from discover language selector will make data.search() called with a specific strategy to use the language config stored in localStorage which is unexpected. With this fix, language config is only used when search strategy is not passed specifically. * Changeset file for PR #8368 created/updated --------- (cherry picked from commit e0776444a144686c59959d9ee1fb36c0f2a7b06e) Signed-off-by: Yulong Ruan Signed-off-by: github-actions[bot] Co-authored-by: github-actions[bot] Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> --- changelogs/fragments/8368.yml | 2 ++ src/plugins/data/public/search/search_service.ts | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/8368.yml diff --git a/changelogs/fragments/8368.yml b/changelogs/fragments/8368.yml new file mode 100644 index 000000000000..473356223888 --- /dev/null +++ b/changelogs/fragments/8368.yml @@ -0,0 +1,2 @@ +fix: +- Data.search() should not ignore the strategy passed as parameter ([#8368](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8368)) \ No newline at end of file diff --git a/src/plugins/data/public/search/search_service.ts b/src/plugins/data/public/search/search_service.ts index 57881b08957f..0c0dd0cb8043 100644 --- a/src/plugins/data/public/search/search_service.ts +++ b/src/plugins/data/public/search/search_service.ts @@ -155,7 +155,7 @@ export class SearchService implements Plugin { ): ISearchStart { const search = ((request, options) => { const isEnhancedEnabled = uiSettings.get(UI_SETTINGS.QUERY_ENHANCEMENTS_ENABLED); - if (isEnhancedEnabled) { + if (isEnhancedEnabled && !options?.strategy) { const queryStringManager = getQueryService().queryString; const language = queryStringManager.getQuery().language; const languageConfig = queryStringManager.getLanguageService().getLanguage(language);