Skip to content

Remove deprecated Elasticsearch query framework#794

Open
axlewin wants to merge 41 commits into
mainfrom
hotfix/remove-deprecated-es
Open

Remove deprecated Elasticsearch query framework#794
axlewin wants to merge 41 commits into
mainfrom
hotfix/remove-deprecated-es

Conversation

@axlewin

@axlewin axlewin commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Removes all usage of BooleanSearchClause and AbstractFilterInstruction-based searching in favour of the newer AbstractInstruction-based pattern. This removes a lot of duplicated logic; there should now be a single, consistent approach to building ES queries across the whole project.

Also removes the generateTemporaryGameboard endpoint, which has been unsupported for over a year. This change is technically unrelated but was needed in order to remove some of the ES framework.

axlewin and others added 24 commits May 26, 2026 17:22
This endpoint has been unsupported for over a year, and for two months
has been inaccessible in production (since 3d839bf).

Several deprecated methods were required for it to work, and without it
these too can be removed. This gets rid of at least one more deprecated
ES method.

Since we no longer generate random gameboards, we no longer have any
need to store temporary boards. The cache can be removed too, but for
now I have just removed the "store new temporary board" method.
No longer needed since all of its methods are superseded by AbstractInstruction-based equivalents
and convertToBoolMap helper method
Deprecated; AbstractFilterInstruction-based searching should use AbstractInstructions instead
Deprecated; AbstractFilterInstruction-based searching should use AbstractInstructions instead
This is superseded by buildBaseInstructions, which is easier to work with for AbstractInstructions (as opposed to AbstractFilterInstructions).
Also remove the tests for the removed methods.

These all used AbstractFilterInstructions. Going forward, AbstractInstruction-based searching should be used instead.
Deprecated in favour of BooleanInstructions
To allow e.g. nofilter quizzes to be viewed. If nofilter content needs to be excluded based on role, this should be handled outside of this manager (e.g. in QuizManager).
@codecov

codecov Bot commented Jun 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 28.96552% with 103 lines in your changes missing coverage. Please review.
✅ Project coverage is 40.39%. Comparing base (03b9dbb) to head (5516d1b).

Files with missing lines Patch % Lines
...n/java/uk/ac/cam/cl/dtg/isaac/api/PagesFacade.java 0.00% 32 Missing ⚠️
...cam/cl/dtg/isaac/api/managers/FastTrackManger.java 0.00% 21 Missing ⚠️
...ac/api/managers/EventNotificationEmailManager.java 0.00% 14 Missing ⚠️
...cam/cl/dtg/segue/dao/schools/SchoolListReader.java 0.00% 14 Missing ⚠️
...bs/DeleteEventAdditionalBookingInformationJob.java 0.00% 8 Missing ⚠️
...am/cl/dtg/segue/dao/content/GitContentManager.java 85.18% 4 Missing ⚠️
...cam/cl/dtg/segue/search/ElasticSearchProvider.java 0.00% 3 Missing ⚠️
.../ac/cam/cl/dtg/isaac/api/managers/GameManager.java 0.00% 2 Missing ⚠️
...ava/uk/ac/cam/cl/dtg/segue/api/GlossaryFacade.java 0.00% 2 Missing ⚠️
.../cl/dtg/segue/api/managers/NotificationPicker.java 0.00% 2 Missing ⚠️
... and 1 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #794      +/-   ##
==========================================
+ Coverage   40.28%   40.39%   +0.10%     
==========================================
  Files         547      541       -6     
  Lines       23814    23389     -425     
  Branches     2898     2828      -70     
==========================================
- Hits         9593     9447     -146     
+ Misses      13320    13077     -243     
+ Partials      901      865      -36     

☔ View full report in Codecov by Harness.
📢 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.

axlewin added 5 commits June 1, 2026 15:38
The "should" clauses should be grouped together and nested in a parent "must" to ensure at least one clause per group is satisfied.
ElasticSearchProvider no longer contains any public helper functions for building queries that can be tested in isolation. It only contains functions that directly interact with the Elasticsearch client which can't easily be tested with unit tests.
If a boolean instruction contains just one match clause, this can be simplified to just a match instruction. Overloading nestedMatchSearch allows us to remove the confusing nesting at the call site whilst still re-using all the existing boolean search functionality.
This nested instruction has no must/filter clauses, so "minimum should match" defaults to 1 anyway.
@axlewin axlewin marked this pull request as ready for review June 5, 2026 10:07

@jsharkey13 jsharkey13 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few questions about subtle filtering behaviour where I think we were, deep under the hood, doing some filtering which this no longer does - because it does not use the new-style builder that does that by default.

Comment thread src/main/java/uk/ac/cam/cl/dtg/segue/dao/content/GitContentManager.java Outdated
Comment thread src/main/java/uk/ac/cam/cl/dtg/segue/dao/content/GitContentManager.java Outdated
Go back to excluding nofilter content by default, and explicitly set the `excludeNofilterContent` property on the base builder when required.
axlewin added 9 commits June 16, 2026 11:45
If a search instruction is built without explicit type filters being passed in, we were defaulting to only returning pages that would be returned by sitewide search. This meant that the search instruction builder - and its more generally useful functionality such as setting base filters - couldn't easily be used in places where we want to return content of _any_ type, unless every possible content type was passed in to the builder.

Instead, if no content types are provided, assume all content types should be returned. The existing places that need to filter  by content type, such as sitewide search, already pass in the appropriate content types anyway so we weren't relying on the previous default behaviour.

This also requires not explicitly setting minimumShouldMatch, since in the case where no content types are provided we no longer require at least one content type to match, so we should let it default to zero. In the case where content types _are_ provided, minimumShouldMatch will default to one anyway, since all of its nested clauses are shoulds.
All events should now have end dates, but this wasn't always the case. To be safe, the initial list of events considered here should include events with a date in the past, in case the end date isn't set.

The logic further down still disregards the date if an end date _is_ set.
The search logic here was identical to that in getUnsafeCachedContentDTOsMatchingIds, so just call the method.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants