You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Log search records with IDs, position, FRBR groups - #481
position is the record’s position in the results sent to the UI. The event captures what the server returned. Visibility and clicks are separate measurements that are not in scope at this time.
Querying the exported data
The separate exporter (coming soon to a PR near you) writes one Parquet row per response. DuckDB can expand the nested list into one row per returned record. Numbering responses before expanding the list keeps repeated searches for the same term distinguishable.
WITH matching_responses AS (
SELECT row_number() OVER () AS response_number,
searchterm,
returned_results
FROM read_parquet('responses.parquet')
WHERE searchterm ='climate change'
)
SELECT response_number, searchterm, r.position, r.api, r.record_id,
r.frbr_group_idFROM matching_responses
CROSS JOIN UNNEST(returned_results) AS result(r)
ORDER BY response_number, r.position;
A zero-match search still has a response row with an empty returned_results list. Analysts can find those by querying the response rows for successful searches with both backend hit totals equal to zero.
NOTE: I have used the PR build for this to log data to CloudWatch and parse it locally into parquet and then queried it via DuckDB.
Developer
Accessibility
ANDI or WAVE has been run in accordance to our guide.
This PR contains no changes to the view layer.
New issues flagged by ANDI or WAVE have been resolved.
New issues flagged by ANDI or WAVE have been ticketed (link in the Pull Request details above).
No new accessibility issues have been flagged.
New ENV
All new ENV is documented in README.
All new ENV has been added to Heroku Pipeline, Staging and Prod.
ENV has not changed.
Approval beyond code review
UXWS/stakeholder approval has been confirmed.
UXWS/stakeholder review will be completed retroactively.
UXWS/stakeholder review is not needed.
Additional context needed to review
E.g., if the PR includes updated dependencies and/or data
migration, or how to confirm the feature is working.
Code Reviewer
Code
I have confirmed that the code works as intended.
Any CodeClimate issues have been fixed or confirmed as
added technical debt.
Documentation
The commit message is clear and follows our guidelines
(not just this pull request message).
The documentation has been updated or is unnecessary.
New dependencies are appropriate or there were no changes.
Testing
There are appropriate tests covering any new functionality.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The logging guard incorrectly records zero results when a Primo continuation notice accompanies nonempty results; it should suppress records only for errors, with tests updated accordingly.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The logging logic can mislabel failed requests as successful and log records never returned by overlooking exception-aware instrumentation and the negotiated response media type.
No open issues 🎉
2 previously missed issues
In code that hasn't changed since last review
Use the response format when logging returned records
app/controllers/search_controller.rb:293
request.format can differ from the format selected by respond_to: with Accept: application/xml, text/html, the response is HTML but the logger treats it as XML. An All-tab response with results from one backend and errors from the other then logs returned IDs even though the HTML view hides them. Use the response's media type, falling back to the request format only when no response type is available.
Log failed requests as errors and suppress returned records
app/controllers/search_controller.rb:299
An unhandled TIMDEX or rendering exception can reach this logging hook while response.status is still 200; Rails supplies the failure status and exception in the process_action payload instead. This currently labels that failed request success and can log loaded records that were never returned. Pass the instrumentation status/exception into these helpers, mark the outcome as error, and suppress returned records for failed requests.
The reason will be displayed to describe this comment to others. Learn more.
I think copilot is right about inaccurately labelling failed requests as having results. I replicated it locally by requesting results in an unsupported format (XML), which returns a 406 with a populated returned_results array. I suspect there's a timing issue around when the exception is set in the controller and when the payload is set in the merged search service.
This branch was successfully deployed
1 active and 1 inactive (outdated)
deployments
timdex-ui-pi-timx730-owcc5u0qj—d4670781DeployedDec 4, 2026 by
JPrevost
timdex-ui-pi-timx730-c53vt5txf—ce003777
Deployed
Oct 30, 2026 by
JPrevost
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://mitlibraries.atlassian.net/browse/TIMX-730
Example Rails log payload
For a search on the All tab, Rails logs one event for the response. Here’s an excerpt showing two returned records:
{ "event_type": "search_results_response", "event_version": 1, "searchterm": "climate change", "search_tab": "all", "response_kind": "initial", "search_outcome": "success", "merge_algorithm": "legacy_zipper", "returned_results_count": 4, "returned_results": [ {"api": "timdex", "record_id": "dspace:123", "position": 1}, { "api": "primo", "record_id": "alma991234", "position": 2, "frbr_group_id": "9005185755117984338" }, {"api": "timdex", "record_id": "dspace:456", "position": 3}, {"api": "primo", "record_id": "alma995678", "position": 4} ] }position is the record’s position in the results sent to the UI. The event captures what the server returned. Visibility and clicks are separate measurements that are not in scope at this time.
Querying the exported data
The separate exporter (coming soon to a PR near you) writes one Parquet row per response. DuckDB can expand the nested list into one row per returned record. Numbering responses before expanding the list keeps repeated searches for the same term distinguishable.
A zero-match search still has a response row with an empty returned_results list. Analysts can find those by querying the response rows for successful searches with both backend hit totals equal to zero.
NOTE: I have used the PR build for this to log data to CloudWatch and parse it locally into parquet and then queried it via DuckDB.
Developer
Accessibility
New ENV
Approval beyond code review
Additional context needed to review
E.g., if the PR includes updated dependencies and/or data
migration, or how to confirm the feature is working.
Code Reviewer
Code
added technical debt.
Documentation
(not just this pull request message).
Testing