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
70 changes: 0 additions & 70 deletions lib/elasticsearch_client.rb

This file was deleted.

14 changes: 0 additions & 14 deletions lib/elasticsearch_response.rb

This file was deleted.

2 changes: 1 addition & 1 deletion lib/index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def documents_by_format(format, field_definitions)
def raw_search(payload)
logger.debug "Request payload: #{payload.to_json}"

ElasticsearchClient.search(index_name: @index_name, body: payload, client: @client)
@client.search(index: @index_name, track_total_hits: true, body: payload)
end

# Convert a best bet query to a string formed by joining the normalised
Expand Down
4 changes: 2 additions & 2 deletions lib/index/elasticsearch_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ def initialize(client:)
end

def save(presenter)
@actions << { index: ElasticsearchClient.compatible_identifier(presenter.identifier) }
@actions << { index: presenter.identifier }
@actions << presenter.document
end

def delete(presenter)
@actions << { delete: ElasticsearchClient.compatible_identifier(presenter.identifier) }
@actions << { delete: presenter.identifier }
end

def commit
Expand Down
2 changes: 1 addition & 1 deletion lib/indexer/popularity_lookup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def traffic_index_size
query: { match_all: {} },
size: 0,
})
ElasticsearchResponse.new(response).total_hits
response.dig("hits", "total", "value")
end
end

Expand Down
2 changes: 0 additions & 2 deletions lib/rummager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@
require "search/suggestion_blocklist"
require "search/timed_cache"

require "elasticsearch_response"
require "index"
require "index_finder"
require "index_group"
Expand All @@ -164,7 +163,6 @@
require "scroll_enumerator"

require "elasticsearch_config"
require "elasticsearch_client"
require "clusters/clusters"
require "clusters/cluster"
require "search_config"
Expand Down
4 changes: 2 additions & 2 deletions lib/schema/index_schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ def es_mappings
"document_type" => @document_type_field,
}
@elasticsearch_types.each_value do |value|
properties = properties.merge(value.es_config)
properties.merge!(value.es_config)
end
ElasticsearchClient.compatible_mappings(properties)
{ "properties" => properties }
end

def elasticsearch_type(elasticsearch_type_name)
Expand Down
2 changes: 1 addition & 1 deletion lib/schema_synchroniser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def initialize(index_name, client = Services.elasticsearch)
end

def sync_mappings(mapping, logger = Logger.new($stdout))
ElasticsearchClient.put_mapping(index_name: @index_name, mapping:, client: @client)
@client.indices.put_mapping(index: @index_name, body: mapping)
logger.info "Updated mappings for index: #{@index_name}"
rescue OpenSearch::Transport::Transport::Errors::BadRequest => e
logger.warn "Unable to update mappings for index: #{@index_name}; #{e.message}"
Expand Down
2 changes: 1 addition & 1 deletion lib/scroll_enumerator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def initialize(client:, index_names:, search_body:, batch_size: DEFAULT_BATCH_SI
@client = client
@index_names = index_names
page = initial_scroll_result(batch_size, search_body)
@size = ElasticsearchResponse.new(page).total_hits
@size = page.dig("hits", "total", "value")

# Pull out the results as they are needed
super() do |yielder|
Expand Down
2 changes: 1 addition & 1 deletion lib/search/aggregate_example_fetcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def prepare_response(slugs, response_list)
result = {}
slugs.zip(response_list) do |slug, response|
result[slug] = {
total: ElasticsearchResponse.new(response).total_hits,
total: response.dig("hits", "total", "value"),
examples: response["hits"]["hits"].map { |hit| apply_multivalued(hit["_source"] || {}) },
}
end
Expand Down
2 changes: 1 addition & 1 deletion lib/search/presenters/result_set_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def initialize(search_params:,
def present
response = {
results: presented_results,
total: ElasticsearchResponse.new(es_response).total_hits || 0,
total: es_response.dig("hits", "total", "value") || 0,
start: search_params.start,
search_params.aggregate_name => presented_aggregates,
suggested_queries:,
Expand Down
2 changes: 1 addition & 1 deletion lib/sitemap/generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def get_all_documents
page = initial_scroll
scroll_id = page["_scroll_id"]
documents = page["hits"]["hits"]
total_documents_count = ElasticsearchResponse.new(page).total_hits
total_documents_count = page.dig("hits", "total", "value")
total_page_count = total_documents_count.fdiv(SCROLL_BATCH_SIZE).ceil
chunk = [homepage]

Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/delete.rake
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace :delete do
id = args[:link]
abort "Missing argument. Usage: rake 'delete:by_link[link]'" if args[:link].nil?

ElasticsearchClient.delete(id:, index_name: SearchConfig.govuk_index_name)
Services.elasticsearch.delete(index: SearchConfig.govuk_index_name, id:)
end

desc "
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/indices.rake
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ the existing data, you will need to run the \"migrate_schema\" task instead, whi
mappings = search_config.schema_config.elasticsearch_mappings(index_name)

synchroniser = SchemaSynchroniser.new(index_name, Services.elasticsearch(cluster:))
synchroniser.sync_mappings(ElasticsearchClient.mappings_properties(mappings), logger)
synchroniser.sync_mappings(mappings, logger)
puts "Successfully synchronised #{index_name} index"
rescue OpenSearch::Transport::Transport::Errors::BadRequest => e
puts "Unable to synchronise index #{index_name} due to #{e.message}"
Expand Down
6 changes: 1 addition & 5 deletions spec/integration/schema_synchroniser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@
synchroniser.sync_mappings(mapping, logger)

response = Services.elasticsearch.indices.get_mapping(index: SearchConfig.govuk_index_name)
if ElasticsearchClient.es7?
expect(response.values.dig(0, "mappings", "properties", "test")).to eq({ "type" => "keyword" })
else
expect(response.values.dig(0, "mappings", "generic-document", "properties", "test")).to eq({ "type" => "keyword" })
end
expect(response.values.dig(0, "mappings", "properties", "test")).to eq({ "type" => "keyword" })
end
end
6 changes: 0 additions & 6 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,6 @@
ClimateControl.modify(TZ: "UTC") { example.run }
end

config.around(:each, :unit) do |example|
ClimateControl.modify(USE_ELASTICSEARCH_7: "true") do
example.run
end
end

if config.files_to_run.one?
config.default_formatter = "doc"
end
Expand Down
2 changes: 1 addition & 1 deletion spec/support/integration_test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def insert_document(index_name, attributes, id: nil, type: "edition", version: n
atts[:link] ||= id

clusters.each do |cluster|
ElasticsearchClient.index(id:, index_name:, atts:, params: version_details, client: client(cluster:))
client(cluster:).index({ index: index_name, id:, body: atts }.merge(version_details))
end

id
Expand Down
Loading
Loading