Add support for query tokenization parameters - #435
Draft
matt-bernhardt wants to merge 1 commit into
Draft
Conversation
❌ 13 blocking issues (15 total)
|
Coverage Report for CI Build 30579192557Coverage decreased (-0.7%) to 97.651%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
| extract_tokenization_params(enhanced_query) | ||
| @query['index'] = ENV.fetch('TIMDEX_INDEX', nil) | ||
| @query['booleanType'] = enhanced_query[:booleanType] | ||
| @query.compact! |
| @@ -238,6 +242,29 @@ def execute_geospatial_query(query) | |||
| end | |||
| # 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" |
| # end | ||
|
|
||
| # VCR.use_cassette('alternate tuning for stock query') do | ||
| # get "/results?q=#{query}&semanticMustBoostThreshold=#{must_alt}&semanticDropBoostThreshold=#{drop_alt}&tab=timdex" |
| http.request(req) | ||
| end | ||
|
|
||
| JSON.parse(res.body) |
| 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 |
| } | ||
| } | ||
| } | ||
| GRAPHQL |
** 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.
| # 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 |
There was a problem hiding this comment.
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 |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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
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