Skip to content

Conversation

@ahopp
Copy link
Contributor

@ahopp ahopp commented Oct 31, 2025

Description

Fixes the Recent Queries button not working for DQL and Lucene query languages in the Discover plugin.

Issues Resolved

Fixes #10810

Root Cause

The Recent Queries feature was broken for DQL (kuery) and Lucene queries due to two issues in the query editor (src/plugins/data/public/ui/query_editor/query_editor.tsx):

Visibility condition bug: The RecentQueriesTable component visibility was gated by isRecentQueryVisible && useQueryEditor. The useQueryEditor flag is false for DQL and Lucene queries, preventing the dropdown from ever showing.

Missing history save: The onSubmit function never called queryString.addToQueryHistory(), so queries were not being saved to history in the first place.

Changelog

src/plugins/data/public/ui/query_editor/query_editor.tsx

Line 487: Removed && useQueryEditor from RecentQueriesTable visibility condition

  • Before: isVisible={isRecentQueryVisible && useQueryEditor}
  • After: isVisible={isRecentQueryVisible}

Lines 157-160: Added queryString.addToQueryHistory() call in onSubmit function

 // Add query to queryString history for Recent Queries feature
 if (currentQuery.query?.trim()) {
   queryString.addToQueryHistory(currentQuery, dateRange);
 }

Testing

Tested locally with DQL and Lucene queries in the Discover plugin:

  • Executed multiple DQL and Lucene queries (e.g., order_id:570663, day_of_week:Thursday)
  • Clicked the "Recent queries" button
  • Verified that the dropdown appears and shows all executed queries
  • Confirmed queries can be re-run by clicking them from the list

DQL:
Image

Lucene:
Image

Check List

  • All tests pass
  • New functionality includes testing
  • Commits are signed per the DCO using --signoff

The Recent Queries button was not working for DQL and Lucene query
languages due to two issues in the query editor:

1. The RecentQueriesTable component visibility was gated by the
   useQueryEditor flag, which is false for DQL/Lucene queries.

2. The onSubmit function never called addToQueryHistory(), so
   queries were not being saved to history in the first place.

This fix removes the useQueryEditor condition from the table visibility
and adds the addToQueryHistory() call in onSubmit to ensure all query
languages are properly saved and displayed in recent queries.

Fixes opensearch-project#10810

Signed-off-by: Andrew Hopp <[email protected]>
@github-actions
Copy link
Contributor

❌ Invalid Changelog Heading

The '## Changelog' heading in your PR description is either missing or malformed. Please make sure that your PR description includes a '## Changelog' heading with proper spelling, capitalization, spacing, and Markdown syntax.

@github-actions
Copy link
Contributor

❌ Changeset File Not Added Yet

Please ensure manual commit for changeset file 10837.yml under folder changelogs/fragments to complete this PR. File still missing.

@ahopp
Copy link
Contributor Author

ahopp commented Oct 31, 2025

Updated PR to align to template and added changeset file for PR

@codecov
Copy link

codecov bot commented Oct 31, 2025

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.70%. Comparing base (c2c7320) to head (b2c79b1).

Files with missing lines Patch % Lines
...ugins/data/public/ui/query_editor/query_editor.tsx 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10837      +/-   ##
==========================================
- Coverage   60.71%   60.70%   -0.01%     
==========================================
  Files        4524     4524              
  Lines      121776   121777       +1     
  Branches    20369    20369              
==========================================
- Hits        73935    73929       -6     
- Misses      42640    42644       +4     
- Partials     5201     5204       +3     
Flag Coverage Δ
Linux_1 26.57% <ø> (ø)
Linux_2 38.88% <ø> (ø)
Linux_3 39.30% <0.00%> (-0.01%) ⬇️
Linux_4 ?
Windows_1 26.59% <ø> (ø)
Windows_2 38.85% <ø> (ø)
Windows_3 39.31% <0.00%> (-0.01%) ⬇️
Windows_4 33.71% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ahopp
Copy link
Contributor Author

ahopp commented Nov 3, 2025

@ananzh, @ashwin-pc, or @abbyhu2000? Thoughts on the code changes?

@ahopp
Copy link
Contributor Author

ahopp commented Nov 4, 2025

Or maybe @TackAdam or @d-buckner? 👀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Discover "Recent queries" button doesn't work with DQL or Lucene

2 participants