Skip to content

Commit

Permalink
fix(queryEnhancements): data.search() should not ignore the `strategy…
Browse files Browse the repository at this point in the history
…` passed as parameter (#8368)

* 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.

Signed-off-by: Yulong Ruan <[email protected]>

* Changeset file for PR #8368 created/updated

---------

Signed-off-by: Yulong Ruan <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
(cherry picked from commit e077644)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 200986a commit 8c61d31
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions changelogs/fragments/8368.yml
Original file line number Diff line number Diff line change
@@ -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))
2 changes: 1 addition & 1 deletion src/plugins/data/public/search/search_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export class SearchService implements Plugin<ISearchSetup, ISearchStart> {
): 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);
Expand Down

0 comments on commit 8c61d31

Please sign in to comment.