From 2d0a459eaca7d4a6613c4a5b3f40fe8b3481673e Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Wed, 20 Oct 2021 16:22:37 -0400 Subject: [PATCH 1/1] LP#1947173: Clean up bad cataloging pot hole If a MARC record has effectively empty fields (all space or punctuation) then it's possible to stumble over a NULL text array when parsing content for the symspell dictionary. This commit checks for that condition and returns early to avoid the problem. Signed-off-by: Mike Rylander Signed-off-by: Galen Charlton --- Open-ILS/src/sql/Pg/300.schema.staged_search.sql | 3 +++ .../src/sql/Pg/upgrade/XXXX.schema.symspell-speed-ingest.sql | 3 +++ 2 files changed, 6 insertions(+) diff --git a/Open-ILS/src/sql/Pg/300.schema.staged_search.sql b/Open-ILS/src/sql/Pg/300.schema.staged_search.sql index d06c56b9d6..dcdb5af5db 100644 --- a/Open-ILS/src/sql/Pg/300.schema.staged_search.sql +++ b/Open-ILS/src/sql/Pg/300.schema.staged_search.sql @@ -1971,6 +1971,9 @@ BEGIN input := evergreen.lowercase(full_input); word_list := ARRAY_AGG(x) FROM search.symspell_parse_words_distinct(input) x; + IF word_list IS NULL THEN + RETURN; + END IF; IF CARDINALITY(word_list) > 1 AND include_phrases THEN RETURN QUERY SELECT * FROM search.symspell_build_raw_entry(input, source_class, TRUE, prefix_length, maxED); diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.symspell-speed-ingest.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.symspell-speed-ingest.sql index 150135794e..e0e660fea7 100644 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.symspell-speed-ingest.sql +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.symspell-speed-ingest.sql @@ -135,6 +135,9 @@ BEGIN input := evergreen.lowercase(full_input); word_list := ARRAY_AGG(x) FROM search.symspell_parse_words_distinct(input) x; + IF word_list IS NULL THEN + RETURN; + END IF; IF CARDINALITY(word_list) > 1 AND include_phrases THEN RETURN QUERY SELECT * FROM search.symspell_build_raw_entry(input, source_class, TRUE, prefix_length, maxED); -- 2.43.2