Skip to content

Commit e79d9fb

Browse files
authored
Merge pull request #1864 from alphagov/update-site_id-organisations-identifier
Update the site_id field which is used to store an index of organisation
2 parents 3df18c0 + f05301f commit e79d9fb

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

app/services/search/solr.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ module Search
22
class Solr
33
RESULTS_PER_PAGE = 20
44
ORGANISATIONS_LIMIT = 3000 # Should match `rows` in https://github.com/alphagov/ckanext-datagovuk/blob/4cfb397/ckanext/datagovuk/lib/cli.py#L398
5+
DGU_ORGANISATIONS_PREFIX = "dgu_organisations".freeze
6+
DGU_ORGANISATIONS_ID = "#{DGU_ORGANISATIONS_PREFIX}_2".freeze # Should match DGU_ORGANISATIONS_ID in https://github.com/alphagov/ckanext-datagovuk/blob/e774ed637178533a47ddfa8fadaf83adc9e903be/ckanext/datagovuk/lib/cli.py#L26
57

68
def self.search(params)
79
query_param = (params["q"] || "").to_s.squish
@@ -24,7 +26,7 @@ def self.build_term_query(query_param)
2426
processed_query = SearchHelper.process_query(query_param)
2527
raise NoSearchTermsError, "Query string is empty after processing" if processed_query.blank?
2628

27-
@query = "(title:(#{processed_query})^2 OR notes:(#{processed_query})) AND NOT site_id:dgu_organisations"
29+
@query = "(title:(#{processed_query})^2 OR notes:(#{processed_query})) AND NOT site_id:#{DGU_ORGANISATIONS_PREFIX}.*"
2830
end
2931

3032
def self.build_filter_query(params)
@@ -92,7 +94,7 @@ def self.get_organisations
9294
query = solr_client.get "select", params: {
9395
q: "*:*",
9496
fq: [
95-
"site_id:dgu_organisations",
97+
"site_id:#{DGU_ORGANISATIONS_ID}",
9698
],
9799
fl: %w[title name],
98100
rows: ORGANISATIONS_LIMIT,
@@ -112,7 +114,7 @@ def self.get_organisation(name)
112114
solr_client.get "select", params: {
113115
q: "*:*",
114116
fq: [
115-
"site_id:dgu_organisations",
117+
"site_id:#{DGU_ORGANISATIONS_ID}",
116118
"name:#{name}",
117119
],
118120
fl: %w[title name extras_contact-email extras_foi-email extras_foi-web extras_foi-name],

spec/services/search/solr_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@
340340
"dataset",
341341
)
342342
expect(term_query).to eq(
343-
"(title:(dataset)^2 OR notes:(dataset)) AND NOT site_id:dgu_organisations",
343+
"(title:(dataset)^2 OR notes:(dataset)) AND NOT site_id:#{described_class::DGU_ORGANISATIONS_PREFIX}.*",
344344
)
345345
end
346346

@@ -350,7 +350,7 @@
350350
)
351351

352352
expect(term_query).to eq(
353-
"(title:(animal health)^2 OR notes:(animal health)) AND NOT site_id:dgu_organisations",
353+
"(title:(animal health)^2 OR notes:(animal health)) AND NOT site_id:#{described_class::DGU_ORGANISATIONS_PREFIX}.*",
354354
)
355355
end
356356

@@ -360,7 +360,7 @@
360360
)
361361

362362
expect(term_query).to eq(
363-
"(title:(\"animal health\")^2 OR notes:(\"animal health\")) AND NOT site_id:dgu_organisations",
363+
"(title:(\"animal health\")^2 OR notes:(\"animal health\")) AND NOT site_id:#{described_class::DGU_ORGANISATIONS_PREFIX}.*",
364364
)
365365
end
366366

@@ -370,7 +370,7 @@
370370
)
371371

372372
expect(term_query).to eq(
373-
"(title:(\"animal health\" dogs)^2 OR notes:(\"animal health\" dogs)) AND NOT site_id:dgu_organisations",
373+
"(title:(\"animal health\" dogs)^2 OR notes:(\"animal health\" dogs)) AND NOT site_id:#{described_class::DGU_ORGANISATIONS_PREFIX}.*",
374374
)
375375
end
376376

@@ -380,7 +380,7 @@
380380
)
381381

382382
expect(term_query).to eq(
383-
"(title:(organogram staff roles salaries)^2 OR notes:(organogram staff roles salaries)) AND NOT site_id:dgu_organisations",
383+
"(title:(organogram staff roles salaries)^2 OR notes:(organogram staff roles salaries)) AND NOT site_id:#{described_class::DGU_ORGANISATIONS_PREFIX}.*",
384384
)
385385
end
386386

@@ -390,7 +390,7 @@
390390
)
391391

392392
expect(term_query).to eq(
393-
"(title:(\"organogram of staff roles & salaries\")^2 OR notes:(\"organogram of staff roles & salaries\")) AND NOT site_id:dgu_organisations",
393+
"(title:(\"organogram of staff roles & salaries\")^2 OR notes:(\"organogram of staff roles & salaries\")) AND NOT site_id:#{described_class::DGU_ORGANISATIONS_PREFIX}.*",
394394
)
395395
end
396396

0 commit comments

Comments
 (0)