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
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,
-- ( 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);
--- /dev/null
+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;