Conversation
❌ 9 blocking issues (12 total)
@qltysh one-click actions:
|
| @@ -103,11 +105,11 @@ def record_id(id:, index:) | |||
| end | |||
|
|
|||
| def search(searchterm:, citation:, contributors:, funding_information:, geodistance:, geobox:, identifiers:, | |||
|
|
||
| def search(searchterm:, citation:, contributors:, funding_information:, geodistance:, geobox:, identifiers:, | ||
| locations:, subjects:, title:, index:, source:, from:, boolean_type:, fulltext:, per_page: 20, **filters) | ||
| locations:, subjects:, title:, index:, source:, from:, boolean_type:, fulltext:, per_page: 20, query_mode: 'keyword', **filters) |
| @@ -135,9 +137,10 @@ def inject_hits_fields_into_source(hits) | |||
| end | |||
|
|
|||
| def construct_query(searchterm, citation, contributors, funding_information, geodistance, geobox, identifiers, | |||
| locations, subjects, title, source, boolean_type, filters, per_page, query_mode) | ||
|
|
||
| results = Opensearch.new.search(from, query, Timdex::OSClient, highlight_requested?, index, fulltext) | ||
| results = Opensearch.new.search(from, query, Timdex::OSClient, highlight: highlight_requested?, index: index, fulltext: fulltext, query_mode: query_mode) |
| MAX_SIZE = 200 | ||
|
|
||
| def search(from, params, client, highlight = false, index = nil, fulltext = false) | ||
| def search(from, params, client, highlight: false, index: nil, fulltext: false, query_mode: 'keyword') |
|
Note that I ran copilot review in a separate draft PR yesterday, to leave us with a cleaner PR for human review. (Copilot had a lot of suggestions.) |
app/models/semantic_query_builder.rb
Outdated
| secret_access_key: ENV.fetch('AWS_SECRET_ACCESS_KEY', nil) | ||
| } | ||
|
|
||
| client = Aws::Lambda::Client.new(client_options) |
There was a problem hiding this comment.
Did you consider an initializer for the Lambda client like we have for the OpenSearch client? Lambda is weird and different so it may not provide the same persistent connection value we get for OpenSearch, but a shared client would allow for consistency with how we manage those external services. This absolutely might be best here as it only moves a few lines to an initializer and that may end up being more confusing to determine where that is occurring. 🤷🏻
There was a problem hiding this comment.
I didn't, but I like that as a way to polish this up a bit!
| LexicalQueryBuilder.new | ||
| end | ||
|
|
||
| builder.build(@params, fulltext: @fulltext) |
There was a problem hiding this comment.
Nice, the pattern we put in place anticipating this is working as cleanly as we hoped.
| OpenSearch::Client.new log: ENV.fetch('OPENSEARCH_LOG', false), url: ENV['OPENSEARCH_URL'] do |config| | ||
| # personal keys use expiring credentials with tokens | ||
| if ENV.fetch('AWS_OPENSEARCH_SESSION_TOKEN', false) | ||
| if ENV['AWS_SESSION_TOKEN'].present? |
There was a problem hiding this comment.
Let's make sure to have all of the affect ENV duplicated in all tiers before this merges please.
Why these changes are being introduced: Now that we have the Semantic Query Builder lambda, we need to integrate it into TIMDEX. Relevant ticket(s): - [USE-411](https://mitlibraries.atlassian.net/browse/USE-411) - [USE-412](https://mitlibraries.atlassian.net/browse/USE-412) How this addresses that need: - Adds SemanticQueryBuilder service to invoke the lambda - Adds queryMode parameter (keyword/semantic) to GraphQL interface - Implements builder selection pattern in Opensearch model - Renames AWS credentials to generic variables (AWS_ACCESS_KEY_ID, etc.) Side effects of this change: - Adds aws-sdk-lambda and mocha as dependencies. - Makes small change to OpenSearch initializer: `ENV.fetch('AWS_SESSION_TOKEN', false)` returns an empty string, which will evaluate to truthy. This has been updated to check for the presence of the env var instead.
Why these changes are being introduced:
Now that we have the Semantic Query Builder lambda, we need to integrate it into TIMDEX.
Relevant ticket(s):
How this addresses that need:
Side effects of this change:
ENV.fetch('AWS_SESSION_TOKEN', false)returns an empty string, which will evaluate to truthy. This has been updated to check for the presence of the env var instead.Developer
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)
Code Reviewer
(not just this pull request message)
Requires database migrations?
NO
Includes new or updated dependencies?
YES