Skip to content
Draft
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
2 changes: 0 additions & 2 deletions elasticsearch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ production: &default
content_index_names: ["government"]
govuk_index_name: "govuk"
auxiliary_index_names: ["page-traffic", "metasearch"]
registry_index: "government"
metasearch_index_name: "metasearch"
page_traffic_index_name: "page-traffic"
popularity_rank_offset: 10
Expand All @@ -21,7 +20,6 @@ test:
content_index_names: ["government_test"]
govuk_index_name: "govuk_test"
auxiliary_index_names: ["page-traffic_test", "metasearch_test"]
registry_index: "government_test"
metasearch_index_name: "metasearch_test"
page_traffic_index_name: "page-traffic_test"
popularity_rank_offset: 10
Expand Down
2 changes: 0 additions & 2 deletions lib/search/presenters/entity_expander.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@ def initialize(registry_name, new_field_name: nil)
end

MAPPINGS = [
Mapping.new(:document_series),
Mapping.new(:document_collections),
Mapping.new(:organisations),
Mapping.new(:policy_areas),
Mapping.new(:world_locations),
Mapping.new(:people),
Mapping.new(:roles),
Expand Down
20 changes: 2 additions & 18 deletions lib/search/registries.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,8 @@ def as_hash
@as_hash ||= {
organisations:,
organisation_content_ids: organisations,

# Whitehall has a thing called `topic`, which is being renamed to "policy
# area", because there already are seven things called "topic". Until
# Whitehall publishes the policy areas with format "policy_area" rather
# than "topic", we will expand `policy_areas` with data from documents
# with format `topic`.
policy_areas: registry_for_document_format("topic"),
document_series: registry_for_document_format("document_series"),
document_collections: registry_for_document_format("document_collection"),
world_locations: registry_for_document_format("world_location"),
document_collections: govuk_registry_for_document_format("document_collection"),
world_locations: govuk_registry_for_document_format("world_location"),
people: govuk_registry_for_document_format("person"),
roles: govuk_registry_for_document_format("ministerial_role"),
}
Expand Down Expand Up @@ -62,14 +54,6 @@ def govuk_index
search_server.index_for_search([SearchConfig.govuk_index_name])
end

def registry_for_document_format(format)
BaseRegistry.new(index, field_definitions, format)
end

def index
search_server.index_for_search([SearchConfig.registry_index])
end

def field_definitions
@field_definitions ||= search_server.schema.field_definitions
end
Expand Down
1 change: 0 additions & 1 deletion lib/search_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ class << self
attr_writer :instance

%w[
registry_index
metasearch_index_name
popularity_rank_offset
auxiliary_index_names
Expand Down
2 changes: 0 additions & 2 deletions lib/tasks/report_inconsistent_aggregate_values.rake
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ task :report_inconsistent_aggregate_values do
# Same as in `lib/search/presenters/entity_expander.rb` minus
# the content_id mappings which are not valid aggregate fields.
aggregates = %w[
document_series
document_collections
organisations
policy_areas
world_locations
people
]
Expand Down
14 changes: 7 additions & 7 deletions spec/unit/result_set_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def sample_docs
"_source" => {
"title" => "Dairy farming and schemes",
"link" => "/dairy-farming-and-schemes",
"policy_areas" => %w[farming],
"document_collections" => %w[farming],
},
}]
end
Expand Down Expand Up @@ -157,21 +157,21 @@ def search_presenter(options)

context "results with a registry" do
before do
policy_area_registry = {
document_collections_registry = {
"farming" => {
"link" => "/government/topics/farming",
"link" => "/government/collections/farming",
"title" => "Farming",
},
}

@output = described_class.new(
search_params: Search::QueryParameters.new(
start: 0,
return_fields: %w[policy_areas],
return_fields: %w[document_collections],
aggregate_name: :aggregates,
),
es_response: sample_es_response,
registries: { policy_areas: policy_area_registry },
registries: { document_collections: document_collections_registry },
).present
end

Expand Down Expand Up @@ -208,10 +208,10 @@ def search_presenter(options)
it "have the expanded topic" do
result = @output[:results][2]
expect([{
"link" => "/government/topics/farming",
"link" => "/government/collections/farming",
"title" => "Farming",
"slug" => "farming",
}]).to eq result["policy_areas"]
}]).to eq result["document_collections"]
end
end
end
Loading