From 672c73587086fd3e3453e53bdde5576b6af4b820 Mon Sep 17 00:00:00 2001 From: dbs Date: Fri, 2 Oct 2009 06:04:34 +0000 Subject: [PATCH] Add a "complete subject" index to support searches of compound subjects composed of topic + temporal + geographic headings Prior to this patch, searches for compound subjects had to be targeted against the keywords index git-svn-id: svn://svn.open-ils.org/ILS/trunk@14250 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/sql/Pg/002.schema.config.sql | 2 +- Open-ILS/src/sql/Pg/950.data.seed-values.sql | 2 ++ .../Pg/upgrade/0030.data.flat-subject-entries.sql | 32 ++++++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/0030.data.flat-subject-entries.sql diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index ee60ad3a1..78899b833 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -51,7 +51,7 @@ CREATE TABLE config.upgrade_log ( install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW() ); -INSERT INTO config.upgrade_log (version) VALUES ('0029'); -- berick +INSERT INTO config.upgrade_log (version) VALUES ('0030'); -- dbs CREATE TABLE config.bib_source ( id SERIAL PRIMARY KEY, diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index f28c76d3a..1239c1c3a 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -43,6 +43,8 @@ INSERT INTO config.metabib_field ( field_class, name, format, xpath ) VALUES -- ( field_class, name, xpath ) VALUES ( 'subject', 'genre', 'mods32', $$//mods32:mods/mods32:genre$$ ); INSERT INTO config.metabib_field ( field_class, name, format, xpath ) VALUES ( 'keyword', 'keyword', 'mods32', $$//mods32:mods/*[not(local-name()='originInfo')]$$ ); -- /* to fool vim */; +INSERT INTO config.metabib_field (field_class, name, format, xpath ) VALUES + ( 'subject', 'complete', 'mods32', $$//mods32:mods/mods32:subject//text()$$ ); INSERT INTO config.non_cataloged_type ( id, owning_lib, name ) VALUES ( 1, 1, oils_i18n_gettext(1, 'Paperback Book', 'cnct', 'name') ); SELECT SETVAL('config.non_cataloged_type_id_seq'::TEXT, 100); diff --git a/Open-ILS/src/sql/Pg/upgrade/0030.data.flat-subject-entries.sql b/Open-ILS/src/sql/Pg/upgrade/0030.data.flat-subject-entries.sql new file mode 100644 index 000000000..1fcab40ec --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0030.data.flat-subject-entries.sql @@ -0,0 +1,32 @@ +BEGIN; + +-- Generate the equivalent of compound subject entries from the existing rows +-- so that we don't have to laboriously reindex them + +INSERT INTO config.upgrade_log (version) VALUES ('0030'); -- dbs + +INSERT INTO config.metabib_field (field_class, name, format, xpath ) VALUES + ( 'subject', 'complete', 'mods32', $$//mods32:mods/mods32:subject//text()$$ ); + +INSERT INTO metabib.subject_field_entry (source, field, value) + SELECT source, ( + SELECT id + FROM config.metabib_field + WHERE field_class = 'subject' AND name = 'complete' + ), + ARRAY_TO_STRING ( + ARRAY ( + SELECT value + FROM metabib.subject_field_entry msfe + WHERE msfe.source = groupee.source + ORDER BY source + ), ' ' + ) AS grouped + FROM ( + SELECT source + FROM metabib.subject_field_entry + GROUP BY source + ) AS groupee + ORDER BY source; + +COMMIT; -- 2.11.0