Skip to content

Commit b646c82

Browse files
committed
WIP - trying to add classes for the new specialist-finder index
1 parent aff014e commit b646c82

17 files changed

+503
-172
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"elasticsearch_types": [
3+
"aaib_report",
4+
"ai_assurance_portfolio_technique",
5+
"algorithmic_transparency_record",
6+
"animal_disease_case",
7+
"asylum_support_decision",
8+
"business_finance_support_scheme",
9+
"cma_case",
10+
"contact",
11+
"countryside_stewardship_grant",
12+
"drcf_digital_markets_research",
13+
"drug_safety_update",
14+
"edition",
15+
"employment_appeal_tribunal_decision",
16+
"employment_tribunal_decision",
17+
"european_structural_investment_fund",
18+
"export_health_certificate",
19+
"farming_grant",
20+
"flood_and_coastal_erosion_risk_management_research_report",
21+
"hmrc_manual",
22+
"hmrc_manual_section",
23+
"international_development_fund",
24+
"licence_transaction",
25+
"life_saving_maritime_appliance_service_station",
26+
"maib_report",
27+
"manual",
28+
"manual_section",
29+
"marine_equipment_approved_recommendation",
30+
"marine_notice",
31+
"medical_safety_alert",
32+
"person",
33+
"policy",
34+
"product_safety_alert_report_recall",
35+
"protected_food_drink_name",
36+
"raib_report",
37+
"research_for_development_output",
38+
"residential_property_tribunal_decision",
39+
"traffic_commissioner_regulatory_decision",
40+
"service_manual_guide",
41+
"service_manual_topic",
42+
"service_standard_report",
43+
"statutory_instrument",
44+
"tax_tribunal_decision",
45+
"utaac_decision",
46+
"veterans_support_organisation"
47+
]
48+
}

elasticsearch.yml

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ production: &default
22
base_uri: <%= ENV["ELASTICSEARCH_URI"] || 'http://localhost:9200' %>
33
content_index_names: ["detailed", "government"]
44
govuk_index_name: "govuk"
5+
specialist_finder_index_name: "specialist-finder"
56
auxiliary_index_names: ["page-traffic", "metasearch"]
67
registry_index: "government"
78
metasearch_index_name: "metasearch"
@@ -23,6 +24,7 @@ test:
2324
base_uri: <%= ENV.fetch('ELASTICSEARCH_URI', 'http://localhost:9200') %>
2425
content_index_names: ["government_test"]
2526
govuk_index_name: "govuk_test"
27+
specialist_finder_index_name: "specialist-finder_test"
2628
auxiliary_index_names: ["page-traffic_test", "metasearch_test"]
2729
registry_index: "government_test"
2830
metasearch_index_name: "metasearch_test"

lib/govuk_index/presenters/common_fields_presenter.rb

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
module GovukIndex
22
class CommonFieldsPresenter
33
CUSTOM_FORMAT_MAP = {
4-
"esi_fund" => "european_structural_investment_fund",
54
"external_content" => "recommended-link",
65
"service_manual_homepage" => "service_manual_guide",
76
"service_manual_service_standard" => "service_manual_guide",

lib/govuk_index/presenters/elasticsearch_presenter.rb

-151
Original file line numberDiff line numberDiff line change
@@ -13,200 +13,53 @@ def type
1313

1414
def document
1515
{
16-
ai_assurance_technique: specialist.ai_assurance_technique,
17-
aircraft_category: specialist.aircraft_category,
18-
aircraft_type: specialist.aircraft_type,
19-
alert_type: specialist.alert_type,
20-
algorithmic_transparency_record_atrs_version: specialist.algorithmic_transparency_record_atrs_version,
21-
algorithmic_transparency_record_capability: specialist.algorithmic_transparency_record_capability,
22-
algorithmic_transparency_record_date_published: specialist.algorithmic_transparency_record_date_published,
23-
algorithmic_transparency_record_function: specialist.algorithmic_transparency_record_function,
24-
algorithmic_transparency_record_organisation: specialist.algorithmic_transparency_record_organisation,
25-
algorithmic_transparency_record_organisation_type: specialist.algorithmic_transparency_record_organisation_type,
26-
algorithmic_transparency_record_other_tags: specialist.algorithmic_transparency_record_other_tags,
27-
algorithmic_transparency_record_phase: specialist.algorithmic_transparency_record_phase,
28-
algorithmic_transparency_record_region: specialist.algorithmic_transparency_record_region,
29-
algorithmic_transparency_record_task: specialist.algorithmic_transparency_record_task,
30-
areas_of_interest: specialist.areas_of_interest,
31-
assessment_date: specialist.assessment_date,
32-
assurance_technique_approach: specialist.assurance_technique_approach,
3316
attachments: common_fields.attachments,
34-
authors: specialist.authors,
35-
business_sizes: specialist.business_sizes,
36-
business_stages: specialist.business_stages,
37-
case_state: specialist.case_state,
38-
case_type: specialist.case_type,
39-
category: specialist.category,
40-
certificate_status: specialist.certificate_status,
41-
class_category: specialist.class_category,
42-
closed_date: specialist.closed_date,
43-
closing_date: specialist.closing_date,
44-
commodity_type: specialist.commodity_type,
4517
contact_groups: details.contact_groups,
4618
content_id: common_fields.content_id,
4719
content_purpose_subgroup: common_fields.content_purpose_subgroup,
4820
content_purpose_supergroup: common_fields.content_purpose_supergroup,
4921
content_store_document_type: common_fields.content_store_document_type,
50-
continuation_link: specialist.continuation_link,
51-
country: specialist.country,
52-
country_of_origin: specialist.country_of_origin,
53-
date_application: specialist.date_application,
54-
date_of_completion: specialist.date_of_completion,
55-
date_of_occurrence: specialist.date_of_occurrence,
56-
date_of_start: specialist.date_of_start,
57-
date_registration: specialist.date_registration,
58-
date_registration_eu: specialist.date_registration_eu,
59-
decision_subject: specialist.decision_subject,
6022
description: common_fields.description,
61-
destination_country: specialist.destination_country,
62-
development_sector: specialist.development_sector,
63-
digital_market_research_area: specialist.digital_market_research_area,
64-
digital_market_research_category: specialist.digital_market_research_category,
65-
digital_market_research_publish_date: specialist.digital_market_research_publish_date,
66-
digital_market_research_publisher: specialist.digital_market_research_publisher,
67-
digital_market_research_topic: specialist.digital_market_research_topic,
68-
disease_case_closed_date: specialist.disease_case_closed_date,
69-
disease_case_opened_date: specialist.disease_case_opened_date,
70-
disease_type: specialist.disease_type,
7123
document_type: type,
72-
eligible_entities: specialist.eligible_entities,
7324
email_document_supertype: common_fields.email_document_supertype,
74-
first_published_at: specialist.first_published_at,
75-
flood_and_coastal_erosion_category: specialist.flood_and_coastal_erosion_category,
7625
format: common_fields.format,
77-
fund_state: specialist.fund_state,
78-
fund_type: specialist.fund_type,
79-
funding_amount: specialist.funding_amount,
80-
funding_source: specialist.funding_source,
8126
government_document_supertype: common_fields.government_document_supertype,
8227
government_name: common_fields.government_name,
83-
grant_type: specialist.grant_type,
84-
hidden_indexable_content: specialist.hidden_indexable_content,
8528
hmrc_manual_section_id: common_fields.section_id,
8629
image_url:,
8730
indexable_content: indexable.indexable_content,
88-
industries: specialist.industries,
89-
internal_notes: specialist.internal_notes,
9031
is_historic: common_fields.historic?,
9132
is_political: common_fields.political?,
9233
is_withdrawn: common_fields.withdrawn?,
93-
issued_date: specialist.issued_date,
94-
keyword: specialist.keyword,
95-
key_function: specialist.key_function,
96-
laid_date: specialist.laid_date,
97-
land_use: specialist.land_use,
98-
land_types: specialist.land_types,
9934
latest_change_note: details.latest_change_note,
10035
licence_identifier: details.licence_identifier,
101-
licence_transaction_continuation_link: specialist.licence_transaction_continuation_link,
102-
licence_transaction_industry: specialist.licence_transaction_industry,
103-
licence_transaction_licence_identifier: specialist.licence_transaction_licence_identifier,
104-
licence_transaction_location: specialist.licence_transaction_location,
105-
licence_transaction_will_continue_on: specialist.licence_transaction_will_continue_on,
10636
licence_short_description: details.licence_short_description,
107-
life_saving_maritime_appliance_service_station_regions: specialist.life_saving_maritime_appliance_service_station_regions,
108-
life_saving_maritime_appliance_type: specialist.life_saving_maritime_appliance_type,
109-
life_saving_maritime_appliance_manufacturer: specialist.life_saving_maritime_appliance_manufacturer,
11037
link: common_fields.link,
111-
location: specialist.location,
11238
mainstream_browse_page_content_ids: expanded_links.mainstream_browse_page_content_ids,
11339
mainstream_browse_pages: expanded_links.mainstream_browse_pages,
11440
manual: details.parent_manual,
115-
marine_notice_topic: specialist.marine_notice_topic,
116-
marine_notice_type: specialist.marine_notice_type,
117-
marine_notice_vessel_type: specialist.marine_notice_vessel_type,
118-
market_sector: specialist.market_sector,
119-
medical_specialism: specialist.medical_specialism,
120-
opened_date: specialist.opened_date,
12141
organisation_content_ids: expanded_links.organisation_content_ids,
12242
organisations: expanded_links.organisations,
123-
outcome_type: specialist.outcome_type,
12443
part_of_taxonomy_tree: expanded_links.part_of_taxonomy_tree,
12544
parts: parts.presented_parts,
126-
payment_types: specialist.payment_types,
12745
people: expanded_links.people,
12846
policy_groups: expanded_links.policy_groups,
12947
popularity: common_fields.popularity,
13048
popularity_b: common_fields.popularity_b,
13149
primary_publishing_organisation: expanded_links.primary_publishing_organisation,
132-
principle: specialist.principle,
133-
product_alert_type: specialist.product_alert_type,
134-
product_category: specialist.product_category,
135-
product_measure_type: specialist.product_measure_type,
136-
product_recall_alert_date: specialist.product_recall_alert_date,
137-
product_risk_level: specialist.product_risk_level,
138-
project_code: specialist.project_code,
139-
project_status: specialist.project_status,
140-
protection_type: specialist.protection_type,
14150
public_timestamp: common_fields.public_timestamp,
14251
publishing_app: common_fields.publishing_app,
143-
railway_type: specialist.railway_type,
144-
reason_for_protection: specialist.reason_for_protection,
145-
reference_number: specialist.reference_number,
146-
regions: specialist.regions,
147-
register: specialist.register,
148-
registered_name: specialist.registered_name,
149-
registration: specialist.registration,
15052
rendering_app: common_fields.rendering_app,
151-
report_type: specialist.report_type,
152-
research_document_type: specialist.research_document_type,
153-
result: specialist.result,
154-
review_status: specialist.review_status,
15553
role_appointments: expanded_links.role_appointments,
15654
roles: expanded_links.roles,
157-
sector: specialist.sector,
158-
service_provider: specialist.service_provider,
159-
sift_end_date: specialist.sift_end_date,
160-
sifting_status: specialist.sifting_status,
16155
slug:,
162-
stage: specialist.stage,
163-
status: specialist.status,
164-
subject: specialist.subject,
16556
taxons: expanded_links.taxons,
166-
theme: specialist.theme,
167-
therapeutic_area: specialist.therapeutic_area,
168-
tiers_or_standalone_items: specialist.tiers_or_standalone_items,
169-
time_registration: specialist.time_registration,
17057
title: common_fields.title,
17158
topical_events: expanded_links.topical_events,
172-
topics: specialist.topics,
173-
traditional_term_grapevine_product_category: specialist.traditional_term_grapevine_product_category,
174-
traditional_term_language: specialist.traditional_term_language,
175-
traditional_term_type: specialist.traditional_term_type,
176-
tribunal_decision_categories: specialist.tribunal_decision_categories,
177-
tribunal_decision_category: specialist.tribunal_decision_category,
178-
tribunal_decision_country: specialist.tribunal_decision_country,
179-
tribunal_decision_decision_date: specialist.tribunal_decision_decision_date,
180-
tribunal_decision_judges: specialist.tribunal_decision_judges,
181-
tribunal_decision_landmark: specialist.tribunal_decision_landmark,
182-
tribunal_decision_reference_number: specialist.tribunal_decision_reference_number,
183-
tribunal_decision_sub_categories: specialist.tribunal_decision_sub_categories,
184-
tribunal_decision_sub_category: specialist.tribunal_decision_sub_category,
185-
types_of_support: specialist.types_of_support,
18659
updated_at: common_fields.updated_at,
187-
use_case: specialist.use_case,
18860
user_journey_document_supertype: common_fields.user_journey_document_supertype,
189-
value_of_funding: specialist.value_of_funding,
190-
vessel_type: specialist.vessel_type,
191-
veterans_support_organisation_health_and_social_care: specialist.veterans_support_organisation_health_and_social_care,
192-
veterans_support_organisation_finance: specialist.veterans_support_organisation_finance,
193-
veterans_support_organisation_legal_and_justice: specialist.veterans_support_organisation_legal_and_justice,
194-
veterans_support_organisation_employment_education_and_training: specialist.veterans_support_organisation_employment_education_and_training,
195-
veterans_support_organisation_housing: specialist.veterans_support_organisation_housing,
196-
veterans_support_organisation_families_and_children: specialist.veterans_support_organisation_families_and_children,
197-
veterans_support_organisation_community_and_social: specialist.veterans_support_organisation_community_and_social,
198-
veterans_support_organisation_region_england: specialist.veterans_support_organisation_region_england,
199-
veterans_support_organisation_region_northern_ireland: specialist.veterans_support_organisation_region_northern_ireland,
200-
veterans_support_organisation_region_scotland: specialist.veterans_support_organisation_region_scotland,
201-
veterans_support_organisation_region_wales: specialist.veterans_support_organisation_region_wales,
20261
view_count: common_fields.view_count,
203-
virus_strain: specialist.virus_strain,
204-
will_continue_on: specialist.will_continue_on,
205-
withdrawn_date: specialist.withdrawn_date,
20662
world_locations: expanded_links.world_locations,
207-
year_adopted: specialist.year_adopted,
208-
zone_restriction: specialist.zone_restriction,
209-
zone_type: specialist.zone_type,
21063
}.reject { |_, v| v.nil? }
21164
end
21265

@@ -283,10 +136,6 @@ def expanded_links
283136
@expanded_links ||= ExpandedLinksPresenter.new(payload["expanded_links"])
284137
end
285138

286-
def specialist
287-
@specialist ||= SpecialistPresenter.new(payload)
288-
end
289-
290139
def newslike?
291140
return false if common_fields.content_store_document_type == "fatality_notice"
292141

lib/index/elasticsearch_processor.rb

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ def self.govuk
88
new(client: GovukIndex::Client)
99
end
1010

11+
def self.specialist_finder
12+
new(client: SpecialistFinderIndex::Client)
13+
end
14+
1115
def initialize(client:)
1216
@client = client
1317
@actions = []

lib/rummager.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@
8787

8888
require "govuk_index/updater"
8989
require "govuk_index/client"
90+
require "specialist_finder_index/client"
9091
require "govuk_index/document_type_mapper"
92+
require "specialist_finder_index/document_type_mapper"
9193
require "govuk_index/page_traffic_job"
9294
require "govuk_index/method_builder"
9395
require "govuk_index/indexable_content_sanitiser"
@@ -101,12 +103,15 @@
101103
require "govuk_index/presenters/elasticsearch_identity"
102104
require "govuk_index/presenters/elasticsearch_delete_presenter"
103105
require "govuk_index/presenters/elasticsearch_presenter"
106+
require "specialist_finder_index/presenters/elasticsearch_presenter"
104107
require "govuk_index/presenters/expanded_links_presenter"
105108
require "govuk_index/presenters/indexable_content_presenter"
106109
require "govuk_index/presenters/parts_presenter"
107-
require "govuk_index/presenters/specialist_presenter"
110+
require "specialist_finder_index/presenters/specialist_presenter"
108111
require "govuk_index/publishing_event_processor"
112+
require "specialist_finder_index/publishing_event_processor"
109113
require "govuk_index/publishing_event_job"
114+
require "specialist_finder_index/publishing_event_job"
110115
require "govuk_index/supertype_updater"
111116
require "govuk_index/supertype_job"
112117
require "govuk_message_queue_consumer"

lib/rummager/app.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def require_authentication(permission)
6666
end
6767

6868
def prevent_access_to_govuk
69-
if index_name == "govuk"
69+
if %w[govuk specialist-finder].include?(index_name)
7070
halt(403, "Actions to govuk index are not allowed via this endpoint, please use the message queue to update this index")
7171
end
7272
end

lib/search_config.rb

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class << self
1010
content_index_names
1111
spelling_index_names
1212
govuk_index_name
13+
specialist_finder_index_name
1314
page_traffic_index_name
1415
].each do |config_method|
1516
define_method config_method do

lib/specialist_finder_index/client.rb

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module SpecialistFinderIndex
2+
class Client < Index::Client
3+
private
4+
5+
def index_name
6+
# rubocop:disable Naming/MemoizedInstanceVariableName
7+
@_index ||= SearchConfig.specialist_finder_index_name
8+
# rubocop:enable Naming/MemoizedInstanceVariableName
9+
end
10+
end
11+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module SpecialistFinderIndex
2+
class DocumentTypeMapper
3+
UNPUBLISHING_TYPES = %w[gone redirect substitute vanish].freeze
4+
5+
def initialize(payload)
6+
@payload = payload
7+
end
8+
9+
def type
10+
@payload["document_type"]
11+
end
12+
13+
def unpublishing_type?
14+
UNPUBLISHING_TYPES.include?(@payload["document_type"])
15+
end
16+
end
17+
end

0 commit comments

Comments
 (0)