From 3b4beecff4b214b44c7d4ad0865a6d874a57b6c8 Mon Sep 17 00:00:00 2001 From: "Michael B. Klein" Date: Mon, 7 Aug 2023 21:57:16 +0000 Subject: [PATCH] Fix collection check on OAI output --- src/handlers/oai/search.js | 3 ++- src/handlers/oai/verbs.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/handlers/oai/search.js b/src/handlers/oai/search.js index 74088375..5dd349e6 100644 --- a/src/handlers/oai/search.js +++ b/src/handlers/oai/search.js @@ -44,9 +44,10 @@ async function oaiSearch(dates, set, size = 250) { { term: { visibility: "Public" } }, range, ], - ...(set && { must: [{ term: { "collection.id": set } }] }), }, }; + if (set) query.bool.must.push({ term: { "collection.id": set } }); + const body = { size, query, diff --git a/src/handlers/oai/verbs.js b/src/handlers/oai/verbs.js index 2a1c2995..d60b10d2 100644 --- a/src/handlers/oai/verbs.js +++ b/src/handlers/oai/verbs.js @@ -32,7 +32,7 @@ function header(work) { datestamp: work.modified_date, }; - if (Object.keys(work.collection).length > 0) { + if (work?.collection && Object.keys(work.collection).length > 0) { fields = { ...fields, setSpec: work.collection.id,