Skip to content

Add support for query tokenization parameters - #435

Draft
matt-bernhardt wants to merge 1 commit into
mainfrom
use-636
Draft

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

Conversation

@matt-bernhardt

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

Copy link
Copy Markdown
Member

This adds support for the 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.

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

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

Side effects
Implementing this feature in this way will mean that we need to keep
more things in sync as we continue to develop the application.

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

❌ 13 blocking issues (15 total)

Tool Category Rule Count
rubocop Lint Method has too many lines. [18/10] 5
rubocop Lint Assignment Branch Condition size for query\_timdex is too high. [<9, 18, 16> 25.71/17] 3
rubocop Style Line is too long. [130/120] 2
rubocop Lint Cyclomatic complexity for query\_timdex is too high. [10/7] 1
rubocop Lint Perceived complexity for query\_timdex is too high. [11/8] 1
rubocop Lint Class has too many lines. [151/100] 1
qlty Structure Function with high complexity (count = 6): process_timdex_response 2

@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 30579192557

Coverage decreased (-0.7%) to 97.651%

Details

  • Coverage decreased (-0.7%) from the base build.
  • Patch coverage: 12 uncovered changes across 1 file (22 of 34 lines covered, 64.71%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
app/controllers/search_controller.rb 22 10 45.45%
Total (5 files) 34 22 64.71%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 1575
Covered Lines: 1538
Line Coverage: 97.65%
Coverage Strength: 85.0 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
@@ -238,6 +242,29 @@ def execute_geospatial_query(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
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
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
http.request(req)
end

JSON.parse(res.body)

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 execute_tuning_query is too high. [<8, 15, 1> 17.03/17] [rubocop:Metrics/AbcSize]


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

Comment thread app/controllers/search_controller.rb
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]

}
}
}
GRAPHQL

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Class has too many lines. [151/100] [rubocop:Metrics/ClassLength]

** 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.
@mitlib
mitlib temporarily deployed to timdex-ui-pi-use-636-06a3xafm9 July 30, 2026 20:27 Inactive
# it is already a hash (for tuning queries). These two formats are standardized into a common shape in
# process_timdex_response.
process_timdex_response(raw, 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.

Found 4 issues:

1. Assignment Branch Condition size for query_timdex is too high. [<9, 18, 16> 25.71/17] [rubocop:Metrics/AbcSize]


2. Cyclomatic complexity for query_timdex is too high. [10/7] [rubocop:Metrics/CyclomaticComplexity]


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


4. Perceived complexity for query_timdex is too high. [11/8] [rubocop:Metrics/PerceivedComplexity]

data: raw.data.to_h,
errors: raw.errors.details.to_h
}
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.

Found 2 issues:

1. Function with high complexity (count = 6): process_timdex_response [qlty:function-complexity]


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

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