Skip to content

Add support for query tokenization parameters - #435

Draft
matt-bernhardt wants to merge 3 commits into
mainfrom
use-636
Draft

Add support for query tokenization parameters#435
matt-bernhardt wants to merge 3 commits into
mainfrom
use-636

Conversation

@matt-bernhardt

@matt-bernhardt matt-bernhardt commented Jul 22, 2026

Copy link
Copy Markdown
Member

This adds support for some query tuning parameters to the search UI. These are not intended for human use, and are marked as experimental in the API documentation, but because our relevance measurement workflow connects to the UI application, we need to add support for them here in some fashion.

Side effect
The application builds links between tabbed displays using the parameters which are supplied - but only based on an allow list. This PR does not currently add these tuning parameters to that allow list, so any human user who tries to supply them will need to continually re-add them to the querystring rather than reyling on clicking around the interface.

I believe this is acceptable, because these parameters are intended for use by our relevance workflow - which adds them automatically without relying on links.

The parameters not being on the allow list, however, also means that when they're present the application logs will include warnings about unpermitted parameters as each tab link is rendered. The messages will look like Unpermitted parameters: semanticMustBoostThreshold, semanticDropBoostThreshold, semanticShortQueryMaxTokens if all three parameters are supplied - and this message will appear once for each tab in the application.

Ticket
https://mitlibraries.atlassian.net/browse/use-636

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.
  • No additional test coverage is required.

@qltysh

qltysh Bot commented Jul 22, 2026

Copy link
Copy Markdown

❌ 6 blocking issues (7 total)

Tool Category Rule Count
rubocop Lint Method has too many lines. [11/10] 2
rubocop Style Line is too long. [130/120] 2
rubocop Lint Assignment Branch Condition size for initialize is too high. [<7, 20, 5> 21.77/17] 1
rubocop Lint Class has too many lines. [550/100] 1
qlty Structure Function with high complexity (count = 5): extract_tokenization_params 1

@mitlib
mitlib temporarily deployed to timdex-ui-pi-use-636-1nr9riqsh July 22, 2026 16:48 Inactive
@mitlib
mitlib temporarily deployed to timdex-ui-pi-use-636-1nr9riqsh July 22, 2026 18:53 Inactive
@coveralls

coveralls commented Jul 22, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 32425848990

Coverage increased (+0.006%) to 98.333%

Details

  • Coverage increased (+0.006%) from the base build.
  • Patch coverage: 11 of 11 lines across 4 files are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 1560
Covered Lines: 1534
Line Coverage: 98.33%
Coverage Strength: 86.4 hits per line

💛 - Coveralls

@mitlib
mitlib temporarily deployed to timdex-ui-pi-use-636-1nr9riqsh July 22, 2026 20:16 Inactive
extract_tokenization_params(enhanced_query)
@query['index'] = ENV.fetch('TIMDEX_INDEX', nil)
@query['booleanType'] = enhanced_query[:booleanType]
@query.compact!

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Found 2 issues:

1. Assignment Branch Condition size for initialize is too high. [<7, 20, 5> 21.77/17] [rubocop:Metrics/AbcSize]


2. Method has too many lines. [15/10] [rubocop:Metrics/MethodLength]

@mitlib
mitlib temporarily deployed to timdex-ui-pi-use-636-06a3xafm9 July 28, 2026 20:37 Inactive
@mitlib
mitlib temporarily deployed to timdex-ui-pi-use-636-06a3xafm9 July 30, 2026 02:07 Inactive
Comment thread app/controllers/search_controller.rb
TimdexBase::Client.query(TimdexSearch::GeodistanceQuery, variables: query)
else
TimdexBase::Client.query(TimdexSearch::BaseQuery, variables: query)
end

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Method has too many lines. [11/10] [rubocop:Metrics/MethodLength]

Comment thread app/controllers/search_controller.rb Outdated
Comment thread app/controllers/search_controller.rb Outdated
Comment thread app/controllers/search_controller.rb Outdated
Comment thread app/controllers/search_controller.rb Outdated
Comment thread app/models/timdex_tuning.rb Outdated
Comment thread app/models/timdex_tuning.rb Outdated
# drop_alt = 0.4

# VCR.use_cassette('default tuning for stock query') do
# get "/results?q=#{query}&semanticMustBoostThreshold=#{must_default}&semanticDropBoostThreshold=#{drop_default}&tab=timdex"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Line is too long. [130/120] [rubocop:Layout/LineLength]

# end

# VCR.use_cassette('alternate tuning for stock query') do
# get "/results?q=#{query}&semanticMustBoostThreshold=#{must_alt}&semanticDropBoostThreshold=#{drop_alt}&tab=timdex"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Line is too long. [122/120] [rubocop:Layout/LineLength]

@mitlib
mitlib temporarily deployed to timdex-ui-pi-use-636-06a3xafm9 July 30, 2026 17:25 Inactive
Comment thread app/controllers/search_controller.rb Outdated
Comment thread app/controllers/search_controller.rb Outdated
next unless enhanced_query[tp.to_sym].present?

@query[tp] = coerce_to_float?(tp) ? enhanced_query[tp.to_sym]&.strip.to_f : enhanced_query[tp.to_sym]&.strip.to_i
end

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Function with high complexity (count = 5): extract_tokenization_params [qlty:function-complexity]

Comment thread app/models/timdex_tuning.rb Outdated
@mitlib
mitlib temporarily deployed to timdex-ui-pi-use-636-06a3xafm9 July 30, 2026 20:27 Inactive
Comment thread app/controllers/search_controller.rb
Comment thread app/controllers/search_controller.rb Outdated
** Why are these changes being introduced:

Our search API recently added support for some optional parameters that
influence how search queries are handled. We can use these parameters
in our query relevance measurement in order to identify the optimal
values, but the UI needs to support them for that happen.

A complication is that these parameters are not included in the public
schema for the API.

** Relevant ticket(s):

* https://mitlibraries.atlassian.net/browse/use-636

** How does this address that need:

This adds support for these three tuning parameters to the UI. It does
this by building a separate pathway for querying the GraphQL API that is
separate from the graphql-client gem. The gem rejects these parameters
because they are not in the API's public schema, so we fall back to
Net::HTTP for this pathway.

** Document any side effects to this change:

Implementing this feature in this way will mean that we need to keep
more things in sync as we continue to develop the application.
With the decision to make tuning parameters a disclosed option,
we no longer need to rely on a separate querying pathway in order
to use them.
@mitlib
mitlib temporarily deployed to timdex-ui-pi-use-636-vwnfipv8i August 19, 2026 15:22 Inactive
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