Skip to content

Commit 41a0593

Browse files
committed
Remove finder tracking from specialist-finder index
The new index should only track specialist documents, as the finder itself is not searchable within the finder and is only needed on govuk wide search
1 parent daa2c10 commit 41a0593

File tree

6 files changed

+123
-20
lines changed

6 files changed

+123
-20
lines changed

lib/govuk_index/presenters/common_fields_presenter.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module GovukIndex
22
class CommonFieldsPresenter
33
CUSTOM_FORMAT_MAP = {
4+
"esi_fund" => "european_structural_investment_fund",
45
"external_content" => "recommended-link",
56
"service_manual_homepage" => "service_manual_guide",
67
"service_manual_service_standard" => "service_manual_guide",

lib/specialist_finder_index/publishing_event_processor.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ def process(messages)
44
messages = Array(messages) # treat a single message as an array with one value
55

66
Services.statsd_client.increment("specialist_finder_index.rabbit-mq-consumed")
7-
PublishingEventJob.perform_async(messages.map { |msg| [msg.delivery_info[:routing_key], msg.payload] })
7+
SpecialistFinderIndex::PublishingEventJob.perform_async(messages.map { |msg| [msg.delivery_info[:routing_key], msg.payload] })
88
messages.each(&:ack)
99
end
1010
end

lib/tasks/message_queue.rake

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ namespace :message_queue do
99
exch = Bunny::Exchange.new(channel, :topic, "published_documents")
1010
channel.queue("search_api_to_be_indexed").bind(exch, routing_key: "*.links")
1111
channel.queue("search_api_bulk_reindex").bind(exch, routing_key: "*.bulk.reindex")
12-
channel.queue("search_api_govuk_index").bind(exch, routing_key: "*.*")
1312
channel.queue("search_api_specialist_finder_index_documents").bind(exch, routing_key: "specialist_document.*")
14-
channel.queue("search_api_specialist_finder_index_finders").bind(exch, routing_key: "finder.*")
13+
channel.queue("search_api_govuk_index").bind(exch, routing_key: "*.*")
1514
end
1615

1716
desc "Index documents that are published to the publishing-api"
@@ -36,10 +35,6 @@ namespace :message_queue do
3635
queue_name: "search_api_specialist_finder_index_documents",
3736
processor: SpecialistFinderIndex::PublishingEventProcessor.new,
3837
).run
39-
GovukMessageQueueConsumer::Consumer.new(
40-
queue_name: "search_api_specialist_finder_index_finders",
41-
processor: SpecialistFinderIndex::PublishingEventProcessor.new,
42-
).run
4338
end
4439

4540
desc "Gets data from RabbitMQ and insert into govuk index (bulk reindex queue)"
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
require "spec_helper"
2+
RSpec.describe "SpecialistFormatsTest" do
3+
before do
4+
bunny_mock = BunnyMock.new
5+
@channel = bunny_mock.start.channel
6+
7+
consumer = GovukMessageQueueConsumer::Consumer.new(
8+
queue_name: "bigwig.test",
9+
processor: GovukIndex::PublishingEventProcessor.new,
10+
rabbitmq_connection: bunny_mock,
11+
)
12+
13+
@queue = @channel.queue("bigwig.test")
14+
consumer.run
15+
end
16+
17+
it "specialist publisher finders are correctly indexed" do
18+
random_example = generate_random_example(
19+
schema: "finder",
20+
payload: { document_type: "finder" },
21+
)
22+
23+
allow(GovukIndex::MigratedFormats).to receive(:indexable_formats).and_return("finder" => :all)
24+
25+
@queue.publish(random_example.to_json, content_type: "application/json")
26+
27+
expect_document_is_in_rummager({ "link" => random_example["base_path"] }, index: "govuk_test", type: "edition")
28+
end
29+
30+
it "specialist documents are correctly indexed" do
31+
document_types = %w[
32+
aaib_report
33+
asylum_support_decision
34+
business_finance_support_scheme
35+
cma_case
36+
countryside_stewardship_grant
37+
drug_safety_update
38+
employment_appeal_tribunal_decision
39+
employment_tribunal_decision
40+
flood_and_coastal_erosion_risk_management_research_report
41+
international_development_fund
42+
licence_transaction
43+
maib_report
44+
medical_safety_alert
45+
protected_food_drink_name
46+
raib_report
47+
research_for_development_output
48+
residential_property_tribunal_decision
49+
service_standard_report
50+
statutory_instrument
51+
tax_tribunal_decision
52+
utaac_decision
53+
]
54+
55+
# ideally we would run a test for all document types, but this takes 3 seconds so I have limited
56+
# it to a random subset
57+
document_types.sample(3).each do |specialist_document_type|
58+
random_example = generate_random_example(
59+
schema: "specialist_document",
60+
payload: { document_type: specialist_document_type },
61+
)
62+
allow(GovukIndex::MigratedFormats).to receive(:indexable_formats).and_return(specialist_document_type => :all)
63+
64+
@queue.publish(random_example.to_json, content_type: "application/json")
65+
66+
expect_document_is_in_rummager({ "link" => random_example["base_path"] }, index: "govuk_test", type: specialist_document_type)
67+
end
68+
end
69+
70+
it "esi documents are correctly indexed" do
71+
publisher_document_type = "esi_fund"
72+
search_document_type = "european_structural_investment_fund"
73+
74+
random_example = generate_random_example(
75+
schema: "specialist_document",
76+
payload: { document_type: publisher_document_type },
77+
)
78+
allow(GovukIndex::MigratedFormats).to receive(:indexable_formats).and_return(search_document_type => :all)
79+
80+
@queue.publish(random_example.to_json, content_type: "application/json")
81+
82+
expect_document_is_in_rummager(
83+
{ "link" => random_example["base_path"], "format" => search_document_type },
84+
index: "govuk_test",
85+
type: search_document_type,
86+
)
87+
end
88+
89+
it "finders email signup are never indexed" do
90+
random_example = generate_random_example(
91+
schema: "finder_email_signup",
92+
payload: { document_type: "finder_email_signup" },
93+
)
94+
95+
@queue.publish(random_example.to_json, content_type: "application/json")
96+
97+
expect {
98+
fetch_document_from_rummager(id: random_example["base_path"], index: "govuk_test")
99+
}.to raise_error(Elasticsearch::Transport::Transport::Errors::NotFound)
100+
end
101+
end

spec/integration/specialist_finder_index/specialist_formats_spec.rb renamed to spec/integration/specialist_finder_index/specialist_documents_spec.rb

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require "spec_helper"
22

3-
RSpec.describe "SpecialistFormatTest" do
3+
RSpec.describe "SpecialistDocumentsTest" do
44
before do
55
bunny_mock = BunnyMock.new
66
@channel = bunny_mock.start.channel
@@ -15,17 +15,6 @@
1515
consumer.run
1616
end
1717

18-
it "specialist publisher finders are correctly indexed" do
19-
random_example = generate_random_example(
20-
schema: "finder",
21-
payload: { document_type: "finder" },
22-
)
23-
24-
@queue.publish(random_example.to_json, content_type: "application/json")
25-
26-
expect_document_is_in_rummager({ "link" => random_example["base_path"] }, index: "specialist-finder_test", type: "finder")
27-
end
28-
2918
it "specialist documents are correctly indexed" do
3019
document_types = %w[
3120
aaib_report
@@ -49,7 +38,6 @@
4938
statutory_instrument
5039
tax_tribunal_decision
5140
utaac_decision
52-
esi_fund
5341
]
5442

5543
# ideally we would run a test for all document types, but this takes 3 seconds so I have limited
@@ -65,4 +53,22 @@
6553
expect_document_is_in_rummager({ "link" => random_example["base_path"] }, index: "specialist-finder_test", type: specialist_document_type)
6654
end
6755
end
56+
57+
it "esi documents are correctly indexed" do
58+
publisher_document_type = "esi_fund"
59+
search_document_type = "european_structural_investment_fund"
60+
61+
random_example = generate_random_example(
62+
schema: "specialist_document",
63+
payload: { document_type: publisher_document_type },
64+
)
65+
66+
@queue.publish(random_example.to_json, content_type: "application/json")
67+
68+
expect_document_is_in_rummager(
69+
{ "link" => random_example["base_path"], "format" => search_document_type },
70+
index: "specialist-finder_test",
71+
type: publisher_document_type,
72+
)
73+
end
6874
end

spec/unit/specialist_finder_index/specialist_formats_spec.rb renamed to spec/unit/specialist_finder_index/presenter/specialist_formats_spec.rb

File renamed without changes.

0 commit comments

Comments
 (0)