Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ may have unexpected consequences if applied to other TIMDEX UI apps.
- `FEATURE_TAB_TIMDEX_ALL`: Display a tab for displaying the combined TIMDEX data. `TIMDEX_INDEX` affects which data appears in this tab.
- `FEATURE_TAB_TIMDEX_ALMA`: Display a tab for displaying Alma data from TIMDEX. `TIMDEX_INDEX` must include `Alma` data or no results will return.
- `FEATURE_TIMDEX_FULLTEXT`: Activate fulltext searching for sources in TIMDEX that support it
- `FEATURE_TIMDEX_SEMANTIC_SEARCH`: Enables semantic query mode (`queryMode: semantic`) for TIMDEX searches. When disabled, TIMDEX defaults to lexical search behavior.
- `FEATURE_PRIMO_NDE_LINKS`: Enables all Primo UI links to target the NDE version of Primo. When enabled, links will use `/nde/search` and `/nde/fulldisplay` paths along with the NDE view ID from `PRIMO_NDE_VID`.
- `FILTER_ACCESS_TO_FILES`: The name to use instead of "Access to files" for that filter / aggregation.
- `FILTER_CONTENT_TYPE`: The name to use instead of "Content type" for that filter / aggregation.
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/search_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ def query_primo(per_page, offset)
end

def execute_geospatial_query(query)
query = query.except('queryMode')

if query['geobox'] == 'true' && query[:geodistance] == 'true'
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

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

execute_geospatial_query checks query[:geodistance], but QueryBuilder populates the geodistance flag under the string key (query['geodistance']). This makes the combined geobox+geodistance branch unreachable and will route those requests to the wrong GraphQL query.

Suggested change
if query['geobox'] == 'true' && query[:geodistance] == 'true'
if query['geobox'] == 'true' && query['geodistance'] == 'true'

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Huh. This is concerning.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah this feels worth confirming the code works as expected. We can do that under another ticket as this change set didn't introduce the potential problem.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it's not introduced here. I think we just never noticed it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

TimdexBase::Client.query(TimdexSearch::AllQuery, variables: query)
elsif query['geobox'] == 'true'
Expand Down
2 changes: 1 addition & 1 deletion app/models/feature.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
class Feature
# List of all valid features in the application
VALID_FEATURES = %i[bot_detection geodata boolean_picker oa_always primo_nde_links simulate_search_latency tab_primo_all tab_timdex_all
tab_timdex_alma record_link timdex_fulltext].freeze
tab_timdex_alma record_link timdex_fulltext timdex_semantic_search].freeze

# Check if a feature is enabled by name
#
Expand Down
1 change: 1 addition & 0 deletions app/models/query_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def initialize(enhanced_query)
extract_query(enhanced_query)
extract_geosearch(enhanced_query)
extract_filters(enhanced_query)
@query['queryMode'] = 'semantic' if Feature.enabled?(:timdex_semantic_search)
@query['index'] = ENV.fetch('TIMDEX_INDEX', nil)
@query['booleanType'] = enhanced_query[:booleanType]
@query.compact!
Comment thread
JPrevost marked this conversation as resolved.
Expand Down
2 changes: 2 additions & 0 deletions app/models/timdex_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class TimdexSearch < TimdexBase
$index: String
$from: String
$booleanType: String
$queryMode: String
$fulltext: Boolean
$perPage: Int
$accessToFilesFilter: [String!]
Expand All @@ -39,6 +40,7 @@ class TimdexSearch < TimdexBase
index: $index
from: $from
booleanType: $booleanType
queryMode: $queryMode
fulltext: $fulltext
perPage: $perPage
accessToFilesFilter: $accessToFilesFilter
Expand Down
10 changes: 10 additions & 0 deletions config/schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1360,6 +1360,16 @@
},
"defaultValue": "\"OR\""
},
{
"name": "queryMode",
"description": "Search mode to use. Defaults to \"lexical\". Options include: \"lexical\", \"semantic\"",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": "\"lexical\""
},
{
"name": "accessToFilesFilter",
"description": "Filter results by access type. Use the `AccessToFiles` aggregation for a list of possible values. Multiple values are ORed.",
Expand Down
12 changes: 12 additions & 0 deletions test/models/query_builder_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,16 @@ class QueryBuilderTest < ActiveSupport::TestCase
}
assert_equal expected, QueryBuilder.new(search).query
end

test 'query builder defaults to lexical mode by omitting queryMode' do
search = { q: 'blah' }
refute_includes(QueryBuilder.new(search).query.keys, 'queryMode')
Comment thread
jazairi marked this conversation as resolved.
end

test 'query builder adds semantic queryMode when feature flag is enabled' do
ClimateControl.modify FEATURE_TIMDEX_SEMANTIC_SEARCH: 'true' do
search = { q: 'blah' }
assert_equal('semantic', QueryBuilder.new(search).query['queryMode'])
end
end
end
39 changes: 20 additions & 19 deletions test/vcr_cassettes/data.yml

Large diffs are not rendered by default.

33 changes: 17 additions & 16 deletions test/vcr_cassettes/data_from_ridiculous_start.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 20 additions & 19 deletions test/vcr_cassettes/data_page_2.yml

Large diffs are not rendered by default.

522 changes: 501 additions & 21 deletions test/vcr_cassettes/timdex_empty_search.yml

Large diffs are not rendered by default.

58 changes: 37 additions & 21 deletions test/vcr_cassettes/timdex_error.yml

Large diffs are not rendered by default.

31 changes: 16 additions & 15 deletions test/vcr_cassettes/timdex_no_results.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

523 changes: 502 additions & 21 deletions test/vcr_cassettes/timdex_null_search.yml

Large diffs are not rendered by default.

Loading