LP825039: Add reingest logic for non-filing titles
authorDan Scott <dscott@laurentian.ca>
Fri, 11 Nov 2011 18:41:33 +0000 (13:41 -0500)
committerDan Scott <dscott@laurentian.ca>
Mon, 14 Nov 2011 21:45:57 +0000 (16:45 -0500)
Rather than reindexing all titles that have a non-filing indicator, this
upgrade handles the known problematic cases (apostrophes with leading
articles). On our system that's 55K out of 2.2M records - not bad at
all.

We also ensure the format is set to MODS32 for title:proper, as sites
might have customized it on a MARC basis and we don't want to reindex
the records with NULL values due to a mix of format and XPath.

Signed-off-by: Dan Scott <dscott@laurentian.ca>
Open-ILS/src/sql/Pg/upgrade/XXXX.fix-nonfiling-titles.sql

index 2ab8a15..0b60466 100644 (file)
@@ -20,7 +20,8 @@ SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
 -- but are you really going to read through the whole XSL below before
 -- seeing this important bit?
 UPDATE config.metabib_field
-    SET xpath = $$//mods32:mods/mods32:titleNonfiling[mods32:title and not (@type)]$$
+    SET xpath = $$//mods32:mods/mods32:titleNonfiling[mods32:title and not (@type)]$$,
+        format = 'mods32'
     WHERE field_class = 'title' AND name = 'proper';
 
 UPDATE config.xml_transform SET xslt=$$<?xml version="1.0" encoding="UTF-8"?>
@@ -3143,3 +3144,13 @@ Added Log Comment
 </xsl:stylesheet>$$ WHERE name = 'mods32';
 
 COMMIT;
+
+-- This could take a long time if you have a very non-English bib database
+-- Run it outside of a transaction to avoid lock escalation
+SELECT metabib.reingest_metabib_field_entries(record)
+    FROM metabib.full_rec
+    WHERE tag = '245'
+    AND ind2 > '0'
+    AND subfield = 'a'
+    AND value LIKE '%''%'
+;