Skip to content

Adds semantic query tuning parameters#971

Open
JPrevost wants to merge 3 commits into
mainfrom
use-619
Open

Adds semantic query tuning parameters#971
JPrevost wants to merge 3 commits into
mainfrom
use-619

Conversation

@JPrevost

Copy link
Copy Markdown
Member

Why are these changes being introduced:

  • We want to be able to tune the semantic query parameters for better results.

Relevant ticket(s):

How does this address that need:

  • Introduces new semantic query tuning parameters to the GraphQL API.
  • Ensures those parameters are not documented publicly by prefixing them with INTERNAL USE ONLY in the description and skipping them in introspection queries.

Developer

  • All new ENV is documented in README
  • All new ENV has been added to Heroku Pipeline, Staging and Prod
  • ANDI or Wave has been run in accordance to
    our guide and
    all issues introduced by these changes have been resolved or opened as new
    issues (link to those issues in the Pull Request details above)
  • Stakeholder approval has been confirmed (or is not needed)

Code Reviewer

  • The commit message is clear and follows our guidelines
    (not just this pull request message)
  • There are appropriate tests covering any new functionality
  • The documentation has been updated or is unnecessary
  • The changes have been verified
  • New dependencies are appropriate or there were no changes

Requires database migrations?

NO

Includes new or updated dependencies?

NO

Why are these changes being introduced:

* We want to be able to tune the semantic query parameters for better
  results.

Relevant ticket(s):

* https://mitlibraries.atlassian.net/browse/USE-619

How does this address that need:

* Introduces new semantic query tuning parameters to the GraphQL API.
* Ensures those parameters are not documented publicly by prefixing them
  with `INTERNAL USE ONLY` in the description and skipping them in
  introspection queries.
@qltysh

qltysh Bot commented Jun 25, 2026

Copy link
Copy Markdown

❌ 9 blocking issues (14 total)

Tool Category Rule Count
rubocop Lint Assignment Branch Condition size for search is too high. [<7, 16, 0> 17.46/17] 3
rubocop Lint Avoid parameter lists longer than 5 parameters. [22/5] 2
rubocop Lint Method has too many lines. [14/10] 2
rubocop Lint Cyclomatic complexity for visible? is too high. [10/7] 1
rubocop Lint Perceived complexity for visible? is too high. [10/8] 1
qlty Structure Function with high complexity (count = 6): visible? 3
qlty Structure Function with many parameters (count = 22): search 2

Comment thread app/graphql/timdex_schema.rb
Comment thread app/graphql/types/query_type.rb Outdated
Comment thread app/graphql/types/query_type.rb Outdated
Comment thread app/graphql/types/query_type.rb Outdated
def search(searchterm:, citation:, contributors:, funding_information:, geodistance:, geobox:, identifiers:,
locations:, subjects:, title:, index:, source:, from:, boolean_type:, fulltext:, per_page: 20,
query_mode: 'keyword', use_global_scoring: false, **filters)
query_mode: 'keyword', use_global_scoring: false, semantic_must_boost_threshold: nil,

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 many parameters (count = 22): search [qlty:function-parameters]


2. Avoid parameter lists longer than 5 parameters. [22/5] [rubocop:Metrics/ParameterLists]

Comment thread app/models/opensearch.rb
@@ -4,12 +4,13 @@ class Opensearch
MAX_SIZE = 200

def search(from, params, client, highlight: false, index: nil, fulltext: false, query_mode: 'keyword',

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 many parameters (count = 10): search [qlty:function-parameters]


2. Avoid parameter lists longer than 5 parameters. [10/5] [rubocop:Metrics/ParameterLists]

@mitlib mitlib temporarily deployed to timdex-api-p-use-619-dises3whb June 25, 2026 19:20 Inactive

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adds internal semantic query tuning knobs to the GraphQL search API and threads them through to the semantic-query Lambda payload, while attempting to hide these knobs from public schema introspection.

Changes:

  • Add semantic_* tuning arguments to GraphQL search and pass them through to OpenSearch query building.
  • Extend Opensearch, HybridQueryBuilder, and SemanticQueryBuilder to accept and forward semantic_options.
  • Add schema-level visibility logic intended to hide “INTERNAL USE ONLY” arguments from introspection.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
app/models/semantic_query_builder.rb Accepts semantic tuning options and conditionally adds them to the Lambda invocation payload.
app/models/opensearch.rb Stores semantic options and passes them only for semantic/hybrid query modes.
app/models/hybrid_query_builder.rb Forwards semantic options into SemanticQueryBuilder.
app/graphql/types/query_type.rb Adds internal GraphQL arguments and constructs the semantic_options hash passed to Opensearch.
app/graphql/timdex_schema.rb Adds visibility hook intended to hide INTERNAL USE ONLY members during introspection.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread app/models/semantic_query_builder.rb Outdated
Comment thread app/models/opensearch.rb Outdated
Comment thread app/graphql/timdex_schema.rb Outdated
Comment thread app/graphql/types/query_type.rb Outdated
Comment thread app/models/semantic_query_builder.rb
return false if is_introspection
end

super

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 3 issues:

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


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


3. Perceived complexity for visible? is too high. [10/8] [rubocop:Metrics/PerceivedComplexity]

Comment thread app/models/opensearch.rb
builder.build(@params, fulltext: @fulltext, semantic_options: @semantic_options || {})
else
builder.build(@params, fulltext: @fulltext)
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): query [qlty:function-complexity]

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Comment thread app/graphql/timdex_schema.rb
Comment thread app/graphql/types/query_type.rb
Comment thread app/graphql/timdex_schema.rb
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