-
Notifications
You must be signed in to change notification settings - Fork 916
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(queryEnhancements): data.search() should not ignore the strategy
passed as parameter
#8368
fix(queryEnhancements): data.search() should not ignore the strategy
passed as parameter
#8368
Conversation
…` 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]>
❌ Empty Changelog SectionThe Changelog section in your PR description is empty. Please add a valid changelog entry or entries. If you did add a changelog entry, check to make sure that it was not accidentally included inside the comment block in the Changelog section. |
❌ Empty Changelog SectionThe Changelog section in your PR description is empty. Please add a valid changelog entry or entries. If you did add a changelog entry, check to make sure that it was not accidentally included inside the comment block in the Changelog section. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8368 +/- ##
=======================================
Coverage 60.92% 60.92%
=======================================
Files 3749 3749
Lines 89021 89021
Branches 13899 13899
=======================================
Hits 54236 54236
Misses 31423 31423
Partials 3362 3362
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@AMoo-Miki @kavilla Can you review this? @ruanyl Can you add details about why this is needed now? |
@ruanyl i dont this the interceptors do that much anymore. afaik the ppl search interceptor should only add the time field to the ppl query from the query state and nothign more. SQL should make no modifications to the query. Is this not whats happening? I agree with you that the inerceptor should not modify anything in the query. I think the time selector is the only exception here but i could be swayed there as well. If this is true, do we still need your change? |
@ashwin-pc You're right, that's true for sql interceptor. For ppl interceptor it adds time filter even when there is a time filter in the ppl query, for example, I have ppl like The actually query send becomes this which adds the time range from the ui
And also it seems it modifies the aggregation which I don't fully understand the reason, maybe it's the default aggregation based on the time range?
We still need this change because this change is about the 1st point for the language selector. The issue that I'm having is I'm using another search strategy, but after I selected PPL or SQL on the discover page, because of the following code, it will always use what's selected(ppl or sql) on discover app even I'm on another app. And actually, it calls
|
I'll let @kavilla answer why we modify aggs. Based on my understanding, we shouldn't. Also adding the time filter even if we already have on in the query is intended behavior to be consistent. If the UI has a time filter, it makes more sense to apply it to the query than not because it simpler to reason that way. Optionally adding it to the query makes it harder to reason when the UI time filter is applied and when the query time filter is used. As for the change you are making, it seems fine temporarily to unblock your usecase but long term the goal is to have a strategy per dataset type and a interceptor per language and this solution breaks that. @kavilla will do a post 2.18 review of the design since we'll have to consolidate all the recent changes we've been making to the search pipeline. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i briefly looked into this, the fix looks good, but how do we know the options.strategy
is supposed to be used with the defaultSearchInteceptor
but not the languageConfig.search
interceptor?
That was my concern as well. |
@ashwin-pc @joshuali925 Both the current
For ppl_search_interceptor:
So this PR won't affect the existing two languageConfig interceptors. However, I'd say this PR is just a temporary workaround to fix the issue that the passed strategy been ignored. I believe we would need a throughly refactor on this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm ok with this temporary workaround. i think it would be good to have some comments to call out that the framework now assumes all search interceptors from language configs do not use options.strategy
and do expect options.strategy
to be absent
@kavilla could you also take a look since you are more familiar with this part
…` 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>
…` 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 e077644) Signed-off-by: Yulong Ruan <[email protected]> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
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 explicitly.
Sharing my two cents:
language
is passed as a parameter todata.search()
instead of reading directly from query string manager(which has default value from local storage that different feature could share the same value). I thinkdata.search()
needs to be UI/feature-agnosticdata.search()
as search params?I may not have a full picture of the entire idea of query enhancement, and I'm open to any other ideas :)
Description
Issues Resolved
Screenshot
Testing the changes
Changelog
Check List
yarn test:jest
yarn test:jest_integration