JBAS-2285 Auth browse prefers lcsh records
authorBill Erickson <berickxx@gmail.com>
Thu, 23 May 2019 18:19:43 +0000 (18:19 +0000)
committerBill Erickson <berickxx@gmail.com>
Thu, 23 May 2019 18:19:43 +0000 (18:19 +0000)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
KCLS/sql/schema/deploy/stock-browse-schema.sql

index ff36e84..2abd7be 100644 (file)
@@ -108,8 +108,14 @@ $FUNK$
         AND acsaf.main_entry IS NULL
         AND NOT are.deleted
         AND cmf.field_class = search_class
-    -- assume the largest record is the best as a tie breaker.
-    ORDER BY LENGTH(are.marc) DESC
+    ORDER BY
+        -- favor 'lcsh' headings over other thesauri,
+        -- falling back to record size as a tie-breaker
+        CASE
+            WHEN ash.thesaurus = 'lcsh' THEN 1000000
+            ELSE LENGTH(are.marc)
+        END
+    DESC
     LIMIT 1;
 $FUNK$ LANGUAGE SQL STABLE;