From c929da18cc5e3b131f617598b5b9e0ea14a142d6 Mon Sep 17 00:00:00 2001 From: Simon Hughesdon Date: Tue, 14 May 2024 12:00:38 +0100 Subject: [PATCH] Remove code reference to reranking [Learning to rank is being removed since this change](https://github.com/alphagov/search-api/pull/2905) --- lib/search/batch_query.rb | 2 +- lib/search/presenters/result_set_presenter.rb | 7 +--- lib/search/query.rb | 5 +-- spec/unit/result_set_presenter_spec.rb | 37 ------------------- 4 files changed, 5 insertions(+), 46 deletions(-) diff --git a/lib/search/batch_query.rb b/lib/search/batch_query.rb index a99cc0a90..78399528f 100644 --- a/lib/search/batch_query.rb +++ b/lib/search/batch_query.rb @@ -11,7 +11,7 @@ def run(searches_params) es_responses = timed_msearch(payloads)["responses"] searches_params.map.with_index do |search_params, i| - process_es_response(search_params, builders[i], payloads[i], es_responses[i], false) + process_es_response(search_params, builders[i], payloads[i], es_responses[i]) end end diff --git a/lib/search/presenters/result_set_presenter.rb b/lib/search/presenters/result_set_presenter.rb index 6099e5a72..b2d83d521 100644 --- a/lib/search/presenters/result_set_presenter.rb +++ b/lib/search/presenters/result_set_presenter.rb @@ -1,7 +1,7 @@ module Search # Presents a combined set of results for a GOV.UK site search class ResultSetPresenter - attr_reader :es_response, :presented_aggregates, :reranked, :search_params + attr_reader :es_response, :presented_aggregates, :search_params # `registries` should be a map from registry names to registries, # which gets passed to the ResultSetPresenter class. For example: @@ -12,8 +12,7 @@ def initialize(search_params:, registries: {}, presented_aggregates: {}, schema: nil, - query_payload: {}, - reranked: false) + query_payload: {}) @es_response = es_response @aggregates = es_response["aggregations"] @@ -22,7 +21,6 @@ def initialize(search_params:, @presented_aggregates = presented_aggregates @schema = schema @query_payload = query_payload - @reranked = reranked end def present @@ -34,7 +32,6 @@ def present suggested_queries:, suggested_autocomplete:, es_cluster: search_params.cluster.key, - reranked:, } if search_params.show_query? diff --git a/lib/search/query.rb b/lib/search/query.rb index a1f416f88..e885409df 100644 --- a/lib/search/query.rb +++ b/lib/search/query.rb @@ -31,7 +31,7 @@ def run(search_params) es_response = process_elasticsearch_errors { timed_raw_search(payload) } - process_es_response(search_params, builder, payload, es_response, false) + process_es_response(search_params, builder, payload, es_response) end private @@ -80,7 +80,7 @@ def process_elasticsearch_errors end end - def process_es_response(search_params, builder, payload, es_response, reranked) + def process_es_response(search_params, builder, payload, es_response) # Augment the response with the suggest result from a separate query. if search_params.suggest_spelling? es_response["suggest"] = run_spell_checks(search_params) @@ -99,7 +99,6 @@ def process_es_response(search_params, builder, payload, es_response, reranked) presented_aggregates:, schema: index.schema, query_payload: payload, - reranked:, ).present end diff --git a/spec/unit/result_set_presenter_spec.rb b/spec/unit/result_set_presenter_spec.rb index 01324c126..9e7899aa4 100644 --- a/spec/unit/result_set_presenter_spec.rb +++ b/spec/unit/result_set_presenter_spec.rb @@ -214,41 +214,4 @@ def search_presenter(options) }]).to eq result["policy_areas"] end end - - context "reranked results" do - before do - @results = { - "hits" => { - "hits" => [], - "total" => 0, - }, - } - end - - it "sets reranked: false" do - output = described_class.new( - search_params: Search::QueryParameters.new( - start: 0, - aggregate_name: :aggregates, - ), - es_response: @results, - reranked: false, - ).present - - expect(output[:reranked]).to eq(false) - end - - it "sets reranked: true" do - output = described_class.new( - search_params: Search::QueryParameters.new( - start: 0, - aggregate_name: :aggregates, - ), - es_response: @results, - reranked: false, - ).present - - expect(output[:reranked]).to eq(false) - end - end end