Add support for query tokenization parameters - #435
Conversation
❌ 21 blocking issues (22 total)
|rubocop|Lint|Class has too many lines. [149/100]|1|❌| |
Coverage Report for CI Build 30507589899Warning Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes. Coverage 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! |
This is necessary to bypass the schema validation that comes for free with the graphql-client gem. No tests yet because this is super rough.
| # errors: raw.errors.details.to_h | ||
| # } | ||
| 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]
| @@ -238,6 +242,29 @@ def execute_geospatial_query(query) | |||
| end | |||
| http.request(req) | ||
| end | ||
|
|
||
| JSON.parse(res.body) |
| end | ||
|
|
||
| def tuning_request?(query) | ||
| tuning_params = %w(semanticMustBoostThreshold semanticDropBoostThreshold semanticShortQueryMaxTokens) |
| tuning_params = %w(semanticMustBoostThreshold semanticDropBoostThreshold semanticShortQueryMaxTokens) | ||
|
|
||
| tuning_params.any? do |term| | ||
| query.keys.include?(term) |
| if tuning_request?(query) | ||
| { | ||
| data: (raw["data"].nil? ? {} : raw["data"]), | ||
| errors: (raw["errors"].nil? ? {} : raw["errors"]) |
There was a problem hiding this comment.
| } | ||
| } | ||
| } | ||
| GRAPHQL |
| @@ -0,0 +1,151 @@ | |||
| class TimdexTuning | |||
| TuningQuery = <<-GRAPHQL | |||
| # 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" |
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