Skip to content

Commit 9b89ca9

Browse files
committed
Fix default index for V2 retrieve queries
Why these changes are being introduced: The Retrieve model uses the default elasticsearch index name for V1 and V2 queries, which means that V2 retrieve queries use the wrong index name. Relevant ticket(s): * https://mitlibraries.atlassian.net/browse/TIMX-185 How this addresses that need: This updates Retrieve#default_index to use the default opensearch index name for V2 queries. Side effects of this change: The regression tests for this pass, but somewhat disingenously as we currently use the same index names in .env.test for elasticsearch and opensearch. We should probably regenerate cassettes with the latest prod data and start using the `all-current` index for V2 queries.
1 parent 24536c7 commit 9b89ca9

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

app/models/retrieve.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def fetch(id, client, index = nil)
1616
end
1717

1818
def default_index
19-
ENV.fetch('ELASTICSEARCH_INDEX', nil)
19+
Flipflop.v2? ? ENV.fetch('OPENSEARCH_INDEX', nil) : ENV.fetch('ELASTICSEARCH_INDEX', nil)
2020
end
2121

2222
def to_filter(id)

test/models/retrieve_test.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
require 'test_helper'
2+
3+
class RetrieveTest < ActiveSupport::TestCase
4+
def setup
5+
@test_strategy = Flipflop::FeatureSet.current.test!
6+
end
7+
8+
test 'graphlv1 uses correct index for retrieve queries' do
9+
@test_strategy.switch!(:v2, false)
10+
assert_equal ENV.fetch('ELASTICSEARCH_INDEX'), Retrieve.new.default_index
11+
end
12+
13+
test 'graphqlv2 uses correct index for retrieve queries' do
14+
@test_strategy.switch!(:v2, true)
15+
assert_equal ENV.fetch('OPENSEARCH_INDEX'), Retrieve.new.default_index
16+
end
17+
end

0 commit comments

Comments
 (0)