Skip to content

[PP-3524] Remove complex sort script for "last_update" order in order…#3018

Merged
dbernstein merged 7 commits intomainfrom
PP-3524-reduce-search-load-by-factoring-out-custom-script-2
Feb 3, 2026
Merged

[PP-3524] Remove complex sort script for "last_update" order in order…#3018
dbernstein merged 7 commits intomainfrom
PP-3524-reduce-search-load-by-factoring-out-custom-script-2

Conversation

@dbernstein
Copy link
Contributor

@dbernstein dbernstein commented Jan 30, 2026

… to reduce search load.

Description

  • Based on my analysis of the value of the work_last_update custom sorting script in the v5.py I determined that the script was not useful enough to justify their high computational cost given how work and license pool timestamps are updated in the live operation of the system.
    This update simply removes the script invocation and uses a simpler sorting method that will hopefully tax the opensearch cluster less. The last_update now simply sorts according to the last_update_time on the work. This timestamp is updated when the metadata or circulation data changes for one of the license pools.

  • Additionally, the calculated "last_update" script has been removed as well. So the value of the "updated" element in the feed will always map to Work.last_update_time.

  • There is one final change in this PR: I have removed the sort by licenesepool.last_updated.

    Since there is no appreciable different between the licensepools.last_update and the works.last_update_time, the ability to order by the licensepool.last_updated is unnecessary because we are now correctly updating the work.last_update_time when any associated license pool changes. Therefore it is not worth maintaining a separate sort option in the sort facet.

Motivation and Context

There is a fair amount of context and analysis here that supports the conclusion to remove the expensive sort script.
https://ebce-lyrasis.atlassian.net/browse/PP-3524

How Has This Been Tested?

Unit tests updated. Needs to be load tested on minotaur.

Checklist

  • I have updated the documentation accordingly.
  • All new and existing tests passed.

@dbernstein dbernstein force-pushed the PP-3524-reduce-search-load-by-factoring-out-custom-script-2 branch from 5ed9084 to 4415704 Compare February 2, 2026 20:50
@codecov
Copy link

codecov bot commented Feb 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.01%. Comparing base (a26ae45) to head (2469a6c).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3018      +/-   ##
==========================================
- Coverage   93.02%   93.01%   -0.02%     
==========================================
  Files         482      481       -1     
  Lines       43650    43589      -61     
  Branches     6066     6054      -12     
==========================================
- Hits        40607    40544      -63     
- Misses       1968     1972       +4     
+ Partials     1075     1073       -2     

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

@dbernstein dbernstein force-pushed the PP-3524-reduce-search-load-by-factoring-out-custom-script-2 branch from b3186f8 to 76c1073 Compare February 3, 2026 17:15
@dbernstein dbernstein force-pushed the PP-3524-reduce-search-load-by-factoring-out-custom-script-2 branch from 76c1073 to 22237cf Compare February 3, 2026 17:17
@dbernstein dbernstein marked this pull request as ready for review February 3, 2026 18:08
@dbernstein dbernstein requested a review from a team February 3, 2026 18:10
Copy link
Member

@jonathangreen jonathangreen left a comment

Choose a reason for hiding this comment

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

Looks good, just a couple comments to take a look at.

if has_script_fields:
# Wrap the Work objects in WorkSearchResult so the
# data from script fields isn't lost.
work = WorkSearchResult(work, hit)
Copy link
Member

Choose a reason for hiding this comment

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

After this change I think WorkSearchResult is dead code. I think this is the only place it was ever created. It should either get cleaned up or at least get a TODO comment to be cleaned up in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll remove.

), # Made up keyword type, because we don't want text fuzzyness on this
"licensepools.available": dict(path="licensepools"),
"licensepools.availability_time": dict(path="licensepools"),
"licensepools.last_updated": dict(path="licensepools"),
Copy link
Member

Choose a reason for hiding this comment

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

This field still exists right? Do we actually want to remove this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point - we might as well leave it in there.

@dbernstein dbernstein merged commit e91756c into main Feb 3, 2026
19 checks passed
@dbernstein dbernstein deleted the PP-3524-reduce-search-load-by-factoring-out-custom-script-2 branch February 3, 2026 21:42
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.

2 participants