From: Bill Erickson Date: Thu, 17 May 2018 14:34:13 +0000 (-0400) Subject: JBAS-1050 Add strip-period title/author indexes X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=0e69e7f2d0b15407543a1af1aa69530e8b51061e;p=working%2FEvergreen.git JBAS-1050 Add strip-period title/author indexes 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 --- diff --git a/KCLS/sql/schema/deploy/search-index-keep-periods.sql b/KCLS/sql/schema/deploy/search-index-keep-periods.sql index fbe1d19bd7..8407daa0ae 100644 --- a/KCLS/sql/schema/deploy/search-index-keep-periods.sql +++ b/KCLS/sql/schema/deploy/search-index-keep-periods.sql @@ -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 diff --git a/KCLS/sql/schema/revert/search-index-keep-periods.sql b/KCLS/sql/schema/revert/search-index-keep-periods.sql index 94e5b35845..b28c752c50 100644 --- a/KCLS/sql/schema/revert/search-index-keep-periods.sql +++ b/KCLS/sql/schema/revert/search-index-keep-periods.sql @@ -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;