-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgobi-test-fuzzy-match.sql
62 lines (56 loc) · 1.16 KB
/
gobi-test-fuzzy-match.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
DROP TABLETABLE IF EXISTS temp_bib_records;
CREATE TEMP TABLE temp_bib_records AS
SELECT
m.record_type_code || m.record_num || 'a' AS bib_rec,
--b. and v. abbreviations must be consistent throughout
(regexp_matches(
v.field_content,
'[0-9]{9,10}[x]{0,1}|[0-9]{12,13}[x]{0,1}', --regex borrowed from PLCH (Ray Voelker)
'i'
)
)[1] as clean_isbn
FROM
sierra_view.bib_record AS b
JOIN
sierra_view.bib_record_location AS l
ON
b.record_id = l.bib_record_id
JOIN
sierra_view.varfield_view AS v
ON
b.id = v.record_id
JOIN
sierra_view.record_metadata AS m
ON
b.record_id = m.id
WHERE
-- b.cataloging_date_gmt > (now() - interval '8 days') --for initial load remove time limit
--AND
v.marc_tag = '020' --ISBNs
AND
b.is_suppressed = 'FALSE'
AND
b.bcode2 != '@' --excluding ebooks
AND
m.campus_code = '' --excluding virtual records
AND
l.location_code NOT LIKE 'h%' --excluding hamilton
AND
l.location_code NOT LIKE 'm%' --excluding middletown
CREATE INDEX index_clean_isbn_bibs ON temp_bib_records;
SELECT
*
FROM
temp_bib_records as t
WHERE
t.clean_isbn
IN
(
"078681859X"
"0313284288"
"9780822590286"
"082259028X"
"0780652975"
"9780780652972"
"9781400066094"
)