From 87c0c8d7ed4eb334dbd084d0ab0040589071b111 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Sun, 20 Feb 2022 12:06:43 -0500 Subject: dbstore: shrink CVE FTS index (test index from 120M to 86M) by removing all IDs except cve_id, concatenating reference tags, and removing severities --- dbstore/sql/feed/search.sql | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'dbstore/sql/feed') diff --git a/dbstore/sql/feed/search.sql b/dbstore/sql/feed/search.sql index cb80470..bc3f946 100644 --- a/dbstore/sql/feed/search.sql +++ b/dbstore/sql/feed/search.sql @@ -2,10 +2,10 @@ -- FIXME: should this be moved to cve/search SELECT COALESCE(json_group_array(json_object( 'cve_id', b.cve_id, - 'nvd_cve_id', printf('CVE-%4d-%04d', b.cve_year, b.cve_num), - 'description', d.value, - 'v3_base_score', e.v3_base_score / 10.0, - 'v3_severity', f.name, + 'nvd_id', c.nvd_id, + 'description', e.value, + 'v3_base_score', f.v3_base_score / 10.0, + 'v3_severity', g.name, 'rank', a.min_rank )), '[]') @@ -18,15 +18,17 @@ SELECT COALESCE(json_group_array(json_object( ) a JOIN cves b ON (b.cve_id = a.cve_id) - JOIN cve_descriptions c + JOIN cve_nvd_ids c ON (c.cve_id = b.cve_id) - JOIN descriptions d - ON (d.desc_id = c.desc_id) - JOIN item_cvss_v3_impacts e - ON (e.item_id = b.item_id) - JOIN severities f - ON (f.severity_id = e.v3_severity_id) + JOIN cve_descriptions d + ON (d.cve_id = b.cve_id) + JOIN descriptions e + ON (e.desc_id = d.desc_id) + JOIN item_cvss_v3_impacts f + ON (f.item_id = b.item_id) + JOIN severities g + ON (g.severity_id = f.v3_severity_id) - WHERE d.lang = 'en' + WHERE e.lang LIKE 'en%' ORDER BY a.min_rank; -- cgit v1.2.3