1
);
+INSERT INTO config.index_normalizer (name, description, func, param_count) VALUES (
+ 'Coded Value Map Normalizer',
+ 'Applies coded_value_map mapping of values',
+ 'coded_value_map_normalizer',
+ 1
+);
+
+
-- make use of the index normalizers
INSERT INTO config.metabib_field_index_norm_map (field,norm)
ORDER BY actor.org_unit_proximity(owner, $1)
$$ LANGUAGE SQL;
+CREATE OR REPLACE FUNCTION evergreen.coded_value_map_normalizer( input TEXT, ctype TEXT )
+ RETURNS TEXT AS $F$
+ SELECT COALESCE(value,$1)
+ FROM config.coded_value_map
+ WHERE ctype = $2 AND code = $1;
+$F$ LANGUAGE SQL;
+
+
--- /dev/null
+-- Evergreen DB patch XXXX.schema.coded-value-map-index-normalizer.sql
+--
+BEGIN;
+
+-- check whether patch can be applied
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+-- create the normalizer
+CREATE OR REPLACE FUNCTION evergreen.coded_value_map_normalizer( input TEXT, ctype TEXT )
+ RETURNS TEXT AS $F$
+ SELECT COALESCE(value,$1)
+ FROM config.coded_value_map
+ WHERE ctype = $2 AND code = $1;
+$F$ LANGUAGE SQL;
+
+-- register the normalizer
+INSERT INTO config.index_normalizer (name, description, func, param_count) VALUES (
+ 'Coded Value Map Normalizer',
+ 'Applies coded_value_map mapping of values',
+ 'coded_value_map_normalizer',
+ 1
+);
+
+COMMIT;