diff --git a/app/lib/search/query.rb b/app/lib/search/query.rb index 18225e6d5..b2793b3cb 100644 --- a/app/lib/search/query.rb +++ b/app/lib/search/query.rb @@ -114,6 +114,7 @@ def fetch_search_response(content_item) def use_v2_api? return false if ActiveModel::Type::Boolean.new.cast(filter_params["use_v1"]) return true if ActiveModel::Type::Boolean.new.cast(filter_params["use_v2"]) + return false if filter_params["world_locations"].present? content_item.base_path == SITE_SEARCH_FINDER_BASE_PATH end diff --git a/spec/lib/search/query_spec.rb b/spec/lib/search/query_spec.rb index 6f7c6c927..87d878447 100644 --- a/spec/lib/search/query_spec.rb +++ b/spec/lib/search/query_spec.rb @@ -122,6 +122,33 @@ def result_item(id, title, score:, popularity:, updated:) end end + context "when filtering by world location on the site search finder" do + subject { described_class.new(content_item, { "world_locations" => "austria" }).search_results } + + let(:content_item) do + ContentItem.new({ + "base_path" => "/search/all", + "details" => { + "facets" => facets, + }, + }) + end + + before do + stub_search.to_return(body: { + "results" => [ + result_item("/i-am-the-v1-api", "I am the v1 API", score: nil, updated: "14-12-19", popularity: 1), + ], + }.to_json) + end + + it "calls the v1 API" do + results = subject.fetch("results") + expect(results.length).to eq(1) + expect(results.first).to match(hash_including("_id" => "/i-am-the-v1-api")) + end + end + context "when searching using a single query" do subject { described_class.new(content_item, filter_params).search_results }