JBAS-1050 Add strip-period title/author indexes
authorBill Erickson <berickxx@gmail.com>
Thu, 17 May 2018 14:34:13 +0000 (10:34 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
Now that we no longer strip periods universally for search indexes, add
title and author indexes that strip periods via normalizer to support
(e.g.) author = 'j.k. rowling' / 'j k rowling' / 'jk rowling'

Signed-off-by: Bill Erickson <berickxx@gmail.com>
KCLS/sql/schema/deploy/search-index-keep-periods.sql
KCLS/sql/schema/revert/search-index-keep-periods.sql

index fbe1d19..8407daa 100644 (file)
@@ -32,6 +32,64 @@ VALUES (
     NULL
 );
 
+INSERT INTO config.metabib_field
+    (field_class, name, label, xpath, weight, format, search_field, browse_field)
+VALUES (
+    'title',
+    'title_strip_periods',
+    'General Title With Periods Removed',
+    $$//index:entry[@index:class = 'title']/index:value$$,
+    5, 'kcls', TRUE, FALSE
+);  
+
+-- call replace('.', '') before search_normalize on title index
+INSERT INTO config.metabib_field_index_norm_map (field, norm, pos, params)
+VALUES ( 
+    (SELECT id FROM config.metabib_field WHERE name = 'title_strip_periods'),
+    12, -- replace
+    0,
+    $$[".",""]$$
+), ( 
+    (SELECT id FROM config.metabib_field WHERE name = 'title_strip_periods'),
+    2, -- split_date_range
+    1,
+    NULL
+), ( 
+    (SELECT id FROM config.metabib_field WHERE name = 'title_strip_periods'),
+    19, -- search_normalize
+    1,
+    NULL
+);
+
+INSERT INTO config.metabib_field
+    (field_class, name, label, xpath, weight, format, search_field, browse_field)
+VALUES (
+    'author',
+    'author_strip_periods',
+    'General Author With Periods Removed',
+    $$//index:entry[@index:class = 'author']/index:value$$,
+    5, 'kcls', TRUE, FALSE
+);  
+
+-- call replace('.', '') before search_normalize on author index
+INSERT INTO config.metabib_field_index_norm_map (field, norm, pos, params)
+VALUES ( 
+    (SELECT id FROM config.metabib_field WHERE name = 'author_strip_periods'),
+    12, -- replace
+    0,
+    $$[".",""]$$
+), ( 
+    (SELECT id FROM config.metabib_field WHERE name = 'author_strip_periods'),
+    2, -- split_date_range
+    1,
+    NULL
+), ( 
+    (SELECT id FROM config.metabib_field WHERE name = 'author_strip_periods'),
+    19, -- search_normalize
+    1,
+    NULL
+);
+
 
 CREATE OR REPLACE FUNCTION biblio.extract_metabib_field_entry ( rid BIGINT, default_joiner TEXT ) RETURNS SETOF metabib.field_entry_template AS $func$
 DECLARE
index 94e5b35..b28c752 100644 (file)
@@ -8,6 +8,17 @@ DELETE FROM config.metabib_field_index_norm_map WHERE field =
 
 DELETE FROM config.metabib_field WHERE name = 'keyword_strip_periods';
 
+DELETE FROM config.metabib_field_index_norm_map WHERE field = 
+    (SELECT id FROM config.metabib_field WHERE name = 'title_strip_periods');
+
+DELETE FROM config.metabib_field WHERE name = 'title_strip_periods';
+
+DELETE FROM config.metabib_field_index_norm_map WHERE field = 
+    (SELECT id FROM config.metabib_field WHERE name = 'author_strip_periods');
+
+DELETE FROM config.metabib_field WHERE name = 'author_strip_periods';
+
+
 CREATE OR REPLACE FUNCTION biblio.extract_metabib_field_entry ( rid BIGINT, default_joiner TEXT ) RETURNS SETOF metabib.field_entry_template AS $func$
 DECLARE
     bib     biblio.record_entry%ROWTYPE;