Bring back "split-brain" indexing normalization
authorMike Rylander <mrylander@gmail.com>
Wed, 12 Jun 2013 15:17:08 +0000 (11:17 -0400)
committerDan Scott <dscott@laurentian.ca>
Thu, 27 Jun 2013 03:43:59 +0000 (23:43 -0400)
Before 2.4-era changes to indexing and search, normalizers were applied
in a way that resulted in different effects on the value and index_vector
columns of metabib.*field_entry tables.  This behavior was lost during
the changes mentioned above, but we need it for several things to work
properly, phrase search and (likely) facets among them.  This commit
brings that behavior back.

See here for the original behavioral documentation:

http://evergreen-ils.org/dokuwiki/doku.php?id=documentation:indexing#field_normalization_settings

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Dan Scott <dscott@laurentian.ca>
Open-ILS/src/sql/Pg/030.schema.metabib.sql

index a047e1e..a989a4f 100644 (file)
@@ -1638,7 +1638,7 @@ BEGIN
                     m.params AS params
               FROM  config.index_normalizer n
                     JOIN config.metabib_field_index_norm_map m ON (m.norm = n.id)
-              WHERE field = NEW.field
+              WHERE field = NEW.field AND m.pos < 0
               ORDER BY m.pos LOOP
                 EXECUTE 'SELECT ' || normalizer.func || '(' ||
                     quote_literal( value ) ||
@@ -1650,8 +1650,28 @@ BEGIN
                     ')' INTO value;
 
         END LOOP;
+
         NEW.value = value;
-    END IF;
+
+        FOR normalizer IN
+            SELECT  n.func AS func,
+                    n.param_count AS param_count,
+                    m.params AS params
+              FROM  config.index_normalizer n
+                    JOIN config.metabib_field_index_norm_map m ON (m.norm = n.id)
+              WHERE field = NEW.field AND m.pos >= 0
+              ORDER BY m.pos LOOP
+                EXECUTE 'SELECT ' || normalizer.func || '(' ||
+                    quote_literal( value ) ||
+                    CASE
+                        WHEN normalizer.param_count > 0
+                            THEN ',' || REPLACE(REPLACE(BTRIM(normalizer.params,'[]'),E'\'',E'\\\''),E'"',E'\'')
+                            ELSE ''
+                        END ||
+                    ')' INTO value;
+
+        END LOOP;
+   END IF;
 
     IF TG_TABLE_NAME::TEXT ~ 'browse_entry$' THEN
         value :=  ARRAY_TO_STRING(